2024-01-30 23:21:17 +01:00
|
|
|
{{/* Count number of gallery on page */}}
|
|
|
|
|
{{- $.Page.Scratch.Add "gallerycount" 1 -}}
|
|
|
|
|
{{ $galno := $.Page.Scratch.Get "gallerycount" }}
|
2024-01-30 12:18:28 +01:00
|
|
|
|
2024-02-01 17:30:46 +01:00
|
|
|
{{/* Load CSS/JS and make sure it is only loaded once */}}
|
|
|
|
|
{{- if eq ($.Page.Scratch.Get "gallerycount") 1 }}
|
|
|
|
|
{{- with resources.Get "scss/snap-gallery.scss" | toCSS }}
|
|
|
|
|
<link rel="stylesheet" href="{{ .RelPermalink }}" crossorigin="anonymous">
|
|
|
|
|
{{- end }}
|
|
|
|
|
<script src="/js/snap-gallery.js"></script>
|
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
|
|
{{/* Initialise index of this gallery */}}
|
|
|
|
|
<script>imageIndex[{{ $galno }}] = 1;</script>
|
|
|
|
|
|
2024-01-30 23:21:17 +01:00
|
|
|
{{/* Initialise variables holding image paths */}}
|
2024-01-30 12:18:28 +01:00
|
|
|
{{ $imgs := slice }}
|
|
|
|
|
|
2024-01-30 12:34:00 +01:00
|
|
|
{{/* Get/sanitise image paths */}}
|
2024-01-30 12:18:28 +01:00
|
|
|
{{ if .Params.isdir }}
|
2024-01-30 12:29:32 +01:00
|
|
|
{{/* Get images from folder, put into map */}}
|
|
|
|
|
{{ $imgdir := print "/static/" .Params.src }}
|
|
|
|
|
{{- range readDir $imgdir -}}
|
|
|
|
|
{{ $imgs = $imgs | append (print $.Params.src "/" .Name ) }}
|
|
|
|
|
{{ end }}
|
2024-01-30 12:18:28 +01:00
|
|
|
{{ else }}
|
2024-01-30 12:29:32 +01:00
|
|
|
{{/* Get images from src Param, separated by comma */}}
|
2024-01-30 12:18:28 +01:00
|
|
|
{{ range (split .Params.src ",") }}
|
|
|
|
|
{{ $imgs = $imgs | append (trim . " ") }}
|
|
|
|
|
{{ end }}
|
|
|
|
|
{{ end }}
|
|
|
|
|
|
2024-02-01 17:30:46 +01:00
|
|
|
{{/* Visible images in separate modes */}}
|
|
|
|
|
{{ $mode := default "gallery" .Params.mode }}
|
|
|
|
|
{{/* Gallery mode */}}
|
|
|
|
|
{{ if eq $mode "gallery" }}
|
2024-02-01 15:25:21 +01:00
|
|
|
{{ partial "gallery" (dict "columns" .Params.columns "minwidth" .Params.minwidth "imgs" $imgs "galno" $galno) }}
|
2024-02-01 17:30:46 +01:00
|
|
|
{{/* Slideshow mode */}}
|
|
|
|
|
{{ else if eq $mode "slideshow" }}
|
|
|
|
|
{{ partial "slideshow" (dict "imgs" $imgs "galno" $galno) }}
|
|
|
|
|
{{/* Set autorotate timer for slideshow */}}
|
2024-02-01 23:52:53 +01:00
|
|
|
<script>const autoSlideshow = setInterval(moveSlideshowItem, 5000, {{ $galno }}, 1);</script>
|
2024-02-01 17:30:46 +01:00
|
|
|
{{ end }}
|
2024-01-30 12:18:28 +01:00
|
|
|
|
2024-02-01 15:25:21 +01:00
|
|
|
{{/* The Modal/Lightbox */}}
|
2024-02-01 15:10:31 +01:00
|
|
|
{{ partial "lightbox" (dict "galno" $galno "imgs" $imgs) }}
|