gcg-website/layouts/shortcodes/slider.html

44 lines
1.9 KiB
HTML

<div class="carousel carousel-dark slide" data-bs-ride="true" id='slider-{{ md5 (.Get "dir") }}'>
{{ $dir := (.Get "dir") }}
{{ with $dir }}
{{ $files := readDir (print "/static/" .) }}
<div class="carousel-indicators">
{{ range $index, $file := $files }}
{{ $isimg := lower $file.Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp|webp|avif|jxl)" }}
{{ if $isimg }}
{{ $linkURL := print $.Site.BaseURL "/" ($.Get "dir") "/" $file.Name | absURL }}
{{ if eq $index 0 }}
<button type="button" data-bs-target="#slider-{{ md5 $dir }}" data-bs-slide-to="{{ $index }}" class="active"></button>
{{ else }}
<button type="button" data-bs-target="#slider-{{ md5 $dir }}" data-bs-slide-to="{{ $index }}"></button>
{{ end }}
{{ end }}
{{ end }}
</div>
<div class="carousel-inner">
{{ range $index, $file := $files }}
{{ $isimg := lower $file.Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp|webp|avif|jxl)" }}
{{ if $isimg }}
{{ $linkURL := print $.Site.BaseURL "/" ($.Get "dir") "/" $file.Name | absURL }}
{{ if eq $index 0 }}
<div class="carousel-item active">
<img src="{{ $linkURL }}" class="d-block w-100">
</div>
{{ else }}
<div class="carousel-item">
<img src="{{ $linkURL }}" class="d-block w-100">
</div>
{{ end }}
{{ end }}
{{ end }}
</div>
{{ end }}
<button class="carousel-control-prev" type="button" data-bs-target="#slider-{{ md5 $dir }}" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Zurück</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#slider-{{ md5 $dir }}" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Vor</span>
</button>
</div>