{{ $sourcePath := .sourcePath | default "images" }} {{ $gallery := site.GetPage $sourcePath }} {{ $imageDataUrl := "" }} {{ $s := slice }} {{ with $gallery }} {{ $images := $gallery.Resources.Match "**.jpg" }} {{ range $images }} {{ $thumbs := partial "gallerydeluxe/create-thumbs.html" . }} {{ $20 := (index $thumbs "20") }} {{ $colors := slice }} {{ if (ge hugo.Version "0.104") }} {{/* .Colors method was added in Hugo 0.104.0 */}} {{ $colors = $20.Colors }} {{ end }} {{ $m := dict "name" .Name "full" .RelPermalink "width" .Width "height" .Height "colors" $colors "20" $20.RelPermalink "100" (index $thumbs "100").RelPermalink "250" (index $thumbs "250").RelPermalink "500" (index $thumbs "500").RelPermalink }} {{ $s = $s | append $m }} {{ end }} {{ $r := $s | jsonify | resources.FromString (printf "%s-gallery.json" $sourcePath) }} {{ if hugo.IsProduction }} {{ $r = $r | minify | fingerprint }} {{ end }} {{ $imageDataUrl = $r.RelPermalink }} {{ else }} {{ errorf "gallerydeluxe: No bundle found in %q. sourcePath must be set to a valid Hugo bundle with JPG images in it." $sourcePath }} {{ end }} {{ return (dict "imageDataUrl" $imageDataUrl ) }}