diff options
author | Francesco <tomaselli.fr@gmail.com> | 2024-05-23 13:09:47 +0200 |
---|---|---|
committer | Francesco <tomaselli.fr@gmail.com> | 2024-05-23 13:09:47 +0200 |
commit | 721a958eafc3ab5c921cb3f95ac1538c0e8964a6 (patch) | |
tree | b7e0574be7d3baa39f9f3e2fda8b0c6cb8cdd83a /layouts | |
parent | 379c37e43ae51cc6823e00c2ce4a6d8bad241592 (diff) |
Image tags for sizing
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/_markup/render-image.html | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 7881b48..25d893e 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,16 +1,29 @@ +{{/* Split URL at # */}} {{ $url := .Destination | safeURL }} - -{{ $class := "" }} {{ $file_name_array := split $url "#" }} -{{ $file_name_len := len $file_name_array }} -{{ $tag := index $file_name_array (sub $file_name_len 1)}} -{{ if eq $tag "dark" }} -{{ $class = "img-dark" }} -{{ else if eq $tag "light" }} -{{ $class = "img-light" }} -{{end }} +{{/* +Iterate over all tags, which are in pos 1 to len array - 1, +and build the img class string as "img-tag1 img-tag2 ..." +*/}} + +{{ $classes := "" }} + +{{ range $idx := seq (sub (len $file_name_array) 1) }} +{{ $tag := index $file_name_array $idx }} +{{ $classes = printf "%s img-%s" $classes $tag}} +{{ end }} + +{{/* Use the computed classes on the rendered figure */}} +<figure class="{{ $classes }}"> + + <div> + <img loading="lazy" alt="{{ .Text }}" src=" {{ $url }}"> + </div> -<figure class="{{ $class }}"> - <img loading="lazy" alt="{{ .Text }}" src=" {{ $url }}"> + {{ with .Title }} + <div class="caption-container"> + <figcaption> {{ . | markdownify}} </figcaption> + </div> + {{ end }} </figure>
\ No newline at end of file |