aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/gallery-walk.html
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-09-15 22:46:37 -0400
committertdro <tdro@noreply.example.com>2022-09-15 22:46:37 -0400
commit7f52e601fdf5f6ca5268d72b21afdaf112562651 (patch)
tree7513ea3856ecef6c35b302a76730e8ad17e52fc2 /themes/default/layouts/partials/gallery-walk.html
parent75895e4ec6b4bddcb0a7c06819cccc10e7a55986 (diff)
downloadcanory-7f52e601fdf5f6ca5268d72b21afdaf112562651.tar.gz
canory-7f52e601fdf5f6ca5268d72b21afdaf112562651.tar.bz2
canory-7f52e601fdf5f6ca5268d72b21afdaf112562651.zip
themes/default/layouts/partials/gallery-walk: Relate pages
Pass context. Break is now available. Don't use image cacher for now.
Diffstat (limited to 'themes/default/layouts/partials/gallery-walk.html')
-rw-r--r--themes/default/layouts/partials/gallery-walk.html41
1 files changed, 25 insertions, 16 deletions
diff --git a/themes/default/layouts/partials/gallery-walk.html b/themes/default/layouts/partials/gallery-walk.html
index 6a43eaf..764fa6d 100644
--- a/themes/default/layouts/partials/gallery-walk.html
+++ b/themes/default/layouts/partials/gallery-walk.html
@@ -1,7 +1,8 @@
-{{- $folder := . -}}
+{{- $folder := .Folder -}}
{{- $files := slice -}}
{{- $dimensions := "320x320" -}}
{{- $author := strings.TrimPrefix "public/" (strings.TrimSuffix "/media/" $folder) -}}
+{{- $prefix := print (partial "function-paths.html" "media") "/" $author "/gallery-walker_" -}}
{{- if fileExists $folder -}}
{{- range readDir $folder -}}
@@ -29,35 +30,43 @@
)
-}}
{{- end -}}
+
+ {{- if eq (len $files) 6 -}}
+ {{- break -}}
+ {{- end -}}
{{- end -}}
- {{- if $files }}
+ {{- if $files -}}
- {{- range first 6 $files }}
+ {{- range $files -}}
{{- with $image := resources.Get .Path -}}
- {{- $image = (
- .Content |
- resources.FromString
- (print (partial "function-paths.html" "media") "/" $author "/gallery-walker_" (path.Base .))).Fit
- (print $dimensions " webp")
- }}
+
+ {{- $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="{{- $image.RelPermalink -}}" type="image/webp" />
- {{- $image = (.Content |
- resources.FromString (print (partial "function-paths.html" "media") "/" $author "/gallery-walker_" (path.Base .))).Fit
- (print $dimensions " png")
- }}
+ <source srcset="{{ $srcset.RelPermalink }}" type="image/webp" />
<img loading="lazy"
- alt="{{- .Name }}"
- title="{{- .Name }}"
+ alt="{{ .Name }}"
+ title="{{ .Name }}"
width="{{ $image.Width }}"
height="{{ $image.Height }}"
src="{{ $image.RelPermalink }}"
/>
</picture>
+ </a>
{{- end -}}
{{- end -}}
+ <gallery-overlay></gallery-overlay>
+
{{- else -}}
<footer>
<code>No media found!</code>