mirror of
https://github.com/Smaug123/static-site-pipeline
synced 2025-10-06 00:38:39 +00:00
26 lines
1.2 KiB
HTML
26 lines
1.2 KiB
HTML
<details>
|
|
{{ $summary := default "Click to view gallery" (.Get "summary") }}
|
|
<summary>{{ $summary }}</summary>
|
|
<div class="gallery">
|
|
{{ $base := .Get "src" }}
|
|
{{ $path := print "static/" (.Get "src") }}
|
|
{{ $galleryName := default "gallery" (.Get "galleryName") }}
|
|
|
|
{{ range (readDir $path) }}
|
|
{{- $thumbext := "-thumb" }}
|
|
{{- $isthumb := .Name | findRE ($thumbext | printf "%s\\.") }}<!-- is the current file a thumbnail image? -->
|
|
{{- $isimg := lower .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp)" }}<!-- is the current file an image? -->
|
|
{{- if and $isimg (not $isthumb) }}
|
|
{{- $thumb := .Name | replaceRE "(\\.[^.]+)" ($thumbext | printf "%s.jpg") }}
|
|
{{- $alttextfile := .Name | replaceRE "(\\..+)" ".md" }}
|
|
{{- $alttext := printf "%s/%s" $path $alttextfile | os.ReadFile }}
|
|
<a data-fancybox="{{ $galleryName }}" data-caption="{{ $alttext }}" href="/{{ $base }}/{{ .Name }}">
|
|
<img src="/{{ $base }}/{{ $thumb }}" width=100 height=100 alt={{ $.Page.RenderString $alttext }}> <br/>
|
|
</a>
|
|
{{- end }}
|
|
{{ end }}
|
|
<script>document.addEventListener('DOMContentLoaded', function() {
|
|
Fancybox.bind('[data-fancybox="{{ $galleryName }}"]', {});
|
|
});</script>
|
|
</div>
|
|
</details> |