|
1 | | -{{ $sourcePath := .sourcePath | default "images" }} |
2 | | -{{ $gallery := site.GetPage $sourcePath }} |
| 1 | +{{/* init.hmlt takes either a slice of .images or a .sourcePath that points to a bundle with images. |
| 2 | + An .id will be calculated if not provided. This will be used to create the URL to the data file. |
| 3 | +*/}} |
| 4 | + |
| 5 | +{{ $images := slice }} |
| 6 | +{{ $galleryIDBase := .id }} |
| 7 | +{{ with .images }} |
| 8 | + {{ $images = . }} |
| 9 | + {{ if not $galleryIDBase }} |
| 10 | + {{ range $images }} |
| 11 | + {{ $galleryIDBase = printf "%s%s" $galleryIDBase .RelPermalink }} |
| 12 | + {{ end }} |
| 13 | + {{ end }} |
| 14 | +{{ else }} |
| 15 | + {{ $sourcePath := .sourcePath | default "images" }} |
| 16 | + {{ if not $galleryIDBase }} |
| 17 | + {{ $galleryIDBase = $sourcePath }} |
| 18 | + {{ end }} |
| 19 | + {{ $gallery := site.GetPage $sourcePath }} |
| 20 | + {{ $images = $gallery.Resources.ByType "image" }} |
| 21 | +{{ end }} |
| 22 | +{{ $galleryID := $galleryIDBase | crypto.FNV32a }} |
3 | 23 | {{ $imageDataUrl := "" }} |
4 | 24 | {{ $s := slice }} |
5 | 25 | {{ $params := site.Params.gallerydeluxe }} |
6 | | -{{ with $gallery.Resources.ByType "image" }} |
| 26 | +{{ with $images }} |
7 | 27 | {{ range . }} |
8 | 28 | {{ $thumbs := partial "gallerydeluxe/create-thumbs.html" . }} |
9 | 29 | {{ $20 := (index $thumbs "20") }} |
|
40 | 60 | }} |
41 | 61 | {{ $s = $s | append $m }} |
42 | 62 | {{ end }} |
43 | | - {{ $r := $s | jsonify | resources.FromString (printf "%s-gallery.json" $sourcePath) }} |
| 63 | + {{ $r := $s | jsonify | resources.FromString (printf "%d-gallery.json" $galleryID ) }} |
44 | 64 | {{ if hugo.IsProduction }} |
45 | 65 | {{ $r = $r | minify | fingerprint }} |
46 | 66 | {{ end }} |
47 | 67 | {{ $imageDataUrl = $r.RelPermalink }} |
48 | 68 | {{ else }} |
49 | | - {{ errorf "gallerydeluxe: No bundle found in %q. sourcePath must be set to a valid Hugo bundle with JPG images in it." $sourcePath }} |
| 69 | + {{ errorf "gallerydeluxe: No images provided. Either 'images' as as slice of images or 'sourcePath' must be set to point to a valid Hugo bundle with JPG images in it." }} |
50 | 70 | {{ end }} |
51 | 71 |
|
52 | 72 | {{ return (dict |
|
0 commit comments