aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/gallery-walk.html
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/layouts/partials/gallery-walk.html')
-rw-r--r--themes/default/layouts/partials/gallery-walk.html96
1 files changed, 39 insertions, 57 deletions
diff --git a/themes/default/layouts/partials/gallery-walk.html b/themes/default/layouts/partials/gallery-walk.html
index c17b0da..6c2206f 100644
--- a/themes/default/layouts/partials/gallery-walk.html
+++ b/themes/default/layouts/partials/gallery-walk.html
@@ -1,8 +1,5 @@
-{{- $folder := .Folder -}}
-{{- $files := slice -}}
-{{- $dimensions := "320x320" -}}
-{{- $author := strings.TrimPrefix "public/" (strings.TrimSuffix "/media/" $folder) -}}
-{{- $prefix := print (partial "function-paths.html" "media") "/" $author "/gallery-walker_" -}}
+{{- $data := slice -}}
+{{- $author := partial "function-authors-data.html" . -}}
{{- $mimes := slice
"image/apng"
@@ -14,60 +11,45 @@
"image/webp"
-}}
-{{- if fileExists $folder -}}
- {{- range readDir $folder -}}
- {{- if not .IsDir -}}
- {{- $file := path.Join $folder .Name -}}
- {{- with resources.Get $file -}}
- {{- if in $mimes (string .MediaType) -}}
- {{-
- $files = $files | append (dict
- "Path" .Name
- )
- -}}
- {{- end -}}
- {{- end -}}
- {{- end -}}
- {{- if eq (len $files) 6 -}}
- {{- break -}}
- {{- end -}}
+{{- range (where .Site.RegularPages "Params.Author" $author.user) -}}
+ {{- if in .Content "<figure>" -}}
+ {{- $data = $data | append (dict
+ "alt" (delimit (findRE `(?sU)alt=".*"` .Content 1) "")
+ "height" (delimit (findRE `(?sU)height=".*"` .Content 1) "")
+ "src" (delimit (findRE `(?sU)src=".*"` .Content 1) "")
+ "srcset" (delimit (findRE `(?sU)srcset=".*"` .Content 1) "")
+ "style" (delimit (findRE `(?sU)style=".*"` .Content 1) "")
+ "title" (delimit (findRE `(?sU)title=".*"` .Content 1) "")
+ "type" (delimit (findRE `(?sU)type=".*"` .Content 1) "")
+ "width" (delimit (findRE `(?sU)width=".*"` .Content 1) "")
+ "relatedHref" .Permalink
+ )
+ -}}
+ {{- end -}}
+ {{- if eq (len $data) 6 -}}
+ {{- break -}}
{{- end -}}
{{- end -}}
-{{- if and $files (resources.Get (index (first 1 $files) 0).Path) -}}
- {{- range $files -}}
- {{- with $image := resources.Get .Path -}}
- {{- if in $mimes (string .MediaType) -}}
- {{- $srcset := (.Content | resources.FromString (print $prefix (path.Base .))).Fit (print $dimensions " webp") -}}
- {{- $image = (.Content | resources.FromString (print $prefix (path.Base .))).Fit (print $dimensions " png") -}}
- {{- $decodedURL := print "/" (replaceRE "-" "/" (path.Base .Name) 2 | replaceRE "-.........webp" "") "/" -}}
- {{- $relatedPage := or (in $decodedURL "/messages/") (in $decodedURL "/feeds/") -}}
-
- {{- if not $relatedPage -}}
- {{- $decodedURL = print "/" $author "/" -}}
- {{- end -}}
-
- <a href="{{ $decodedURL }}">
- <picture>
- <source srcset="{{ $srcset.RelPermalink }}" type="image/webp" />
- <img loading="lazy"
- alt="{{ .Name }}"
- title="{{ .Name }}"
- width="{{ $image.Width }}"
- height="{{ $image.Height }}"
- src="{{ $image.RelPermalink }}"
- {{ printf `style="` | safeHTMLAttr -}}
- {{- partial "styles-image-gradient.html" $image.Colors | safeHTMLAttr -}}
- {{- printf `"` | safeHTMLAttr }}
- />
- </picture>
- </a>
- {{- end -}}
- {{- end -}}
- {{- end -}}
+{{- if $data -}}
+ {{- range $image := $data }}
+ <a href="{{ $image.relatedHref }}">
+ <picture>
+ <source
+ {{ $image.srcset | safeHTMLAttr }}
+ {{ $image.type | safeHTMLAttr }}
+ />
+ <img
+ loading="lazy"
+ {{ $image.alt | safeHTMLAttr }}
+ {{ $image.title | safeHTMLAttr }}
+ {{ $image.width | safeHTMLAttr }}
+ {{ $image.height | safeHTMLAttr }}
+ {{ $image.src | safeHTMLAttr }}
+ {{ $image.style | safeHTMLAttr }}
+ />
+ </picture>
+ </a>
+ {{ end }}
<gallery-overlay></gallery-overlay>
-{{- else -}}
- <footer>
- <code>No media found!</code>
- </footer>
{{- end -}}