Commit 1284d821 authored by Phu Nguyen's avatar Phu Nguyen

Update a condition in shortcodes

It turns out that my test was bad, and the condition in the previous commit was not enough
parent 391d1404
<div class="box">
<picture class="img-fluid"> {{ $darkname := print (substr (.Get "src") 0 -4) "-dark.png" }} {{ if or (fileExists (print "static/" .Page.File.Dir .Page.File.BaseFileName "/" $darkname)) (fileExists $darkname) }} <source srcset="{{ .Page.Permalink }}{{ $darkname }}" media="(prefers-color-scheme: dark)"> {{ end }}
<picture class="img-fluid"> {{ $darkname := print (substr (.Get "src") 0 -4) "-dark.png" }} {{ if or (fileExists (print "static/" .Page.File.Dir .Page.File.BaseFileName "/" $darkname)) (fileExists (print "/" .Page.File.Dir $darkname)) }} <source srcset="{{ .Page.Permalink }}{{ $darkname }}" media="(prefers-color-scheme: dark)"> {{ end }}
<img src="{{ .Page.Permalink }}{{ .Get "src" }}" class="img-fluid" alt="{{ .Get "alt" }}" loading="lazy" />
</picture>
</div>
......@@ -3,7 +3,7 @@
{{ .Inner | $.Page.RenderString }}
</div>
<div>
<picture class="img-fluid"> {{ $darkname := print (substr (.Get "src") 0 -4) "-dark.png" }} {{ if or (fileExists (print "static/" .Page.File.Dir .Page.File.BaseFileName "/" $darkname)) (fileExists $darkname) }} <source srcset="{{ .Page.Permalink }}{{ $darkname }}" media="(prefers-color-scheme: dark)"> {{ end }}
<picture class="img-fluid"> {{ $darkname := print (substr (.Get "src") 0 -4) "-dark.png" }} {{ if or (fileExists (print "static/" .Page.File.Dir .Page.File.BaseFileName "/" $darkname)) (fileExists (print "/" .Page.File.Dir $darkname)) }} <source srcset="{{ .Page.Permalink }}{{ $darkname }}" media="(prefers-color-scheme: dark)"> {{ end }}
<img src="{{ .Page.Permalink }}{{ .Get "src" }}" class="img-fluid" alt="{{ .Get "alt" }}" loading="lazy" />
</picture>
</div>
......
......@@ -9,7 +9,7 @@
{{ end }}
<img src="{{ .Get "src" }}" class="img-fluid" alt="{{ .Get "alt" }}" loading="lazy" />
{{ else }}
{{ if or (fileExists (print "static/" .Page.File.Dir .Page.File.BaseFileName "/" $darkname)) (fileExists $darkname) }}
{{ if or (fileExists (print "static/" .Page.File.Dir .Page.File.BaseFileName "/" $darkname)) (fileExists (print "/" .Page.File.Dir $darkname)) }}
<source srcset="{{ .Page.Permalink }}{{ $darkname }}" media="(prefers-color-scheme: dark)">
{{ end }}
<img src="{{ .Page.Permalink }}{{ .Get "src" }}" class="img-fluid" alt="{{ .Get "alt" }}" loading="lazy" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment