selfprivacy.org/layouts/shortcodes/responsive-carousel.html
2024-12-11 21:46:27 +03:00

52 lines
2.3 KiB
HTML

{{ $lang := .Page.Lang }}
{{ $srcFiles := (resources.Match (printf "images/screenshots/%s/*" $lang)) }}
{{ $tinyw := default "500" }}
{{ $smallw := default "800" }}
{{ $mediumw := default "1200" }}
{{ $largew := default "2400" }}
<div id="screenshotsCarouselControls" class="carousel slide" data-bs-ride="false">
<div class="carousel-indicators">
{{ range $i, $src := $srcFiles }}
<button type="button" data-bs-target="#screenshotsCarouselControls" data-bs-slide-to="{{ $i }}" {{ if eq $i 0 }} class="active" aria-current="true" {{ end }}></button>
{{ end }}
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#screenshotsCarouselControls" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#screenshotsCarouselControls" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
<div class="carousel-inner rounded">
{{ range $i, $src := $srcFiles }}
{{ $tiny := $src.Resize (printf "%sx" $tinyw) }}
{{ $small := $src.Resize (printf "%sx" $smallw) }}
{{ $medium:= $src.Resize (printf "%sx" $mediumw) }}
{{ $large := $src.Resize (printf "%sx" $largew) }}
<div class="carousel-item {{ if eq $i 0 }} active {{ end }}">
<img
class = "d-block w-100"
srcset='
{{ with $tiny.RelPermalink }} {{.}} {{(printf "%sw" $tinyw)}} {{ end }},
{{ with $small.RelPermalink }} {{.}} {{(printf "%sw" $smallw)}} {{ end }},
{{ with $medium.RelPermalink }} {{.}} {{(printf "%sw" $mediumw)}} {{ end }},
{{ with $large.RelPermalink }} {{.}} {{(printf "%sw" $largew)}} {{ end }}
'
sizes='
(max-width: {{(printf "%spx" $tinyw)}}) {{(printf "%spx" $tinyw)}},
(max-width: {{(printf "%spx" $smallw)}}) {{(printf "%spx" $smallw)}},
(max-width: {{(printf "%spx" $mediumw)}}) {{(printf "%spx" $mediumw)}},
(max-width: {{(printf "%spx" $largew)}}) {{(printf "%spx" $largew)}},
100%
'
>
</div>
{{ end }}
</div>
</div>