diff options
-rw-r--r-- | themes/default/layouts/partials/function-caches-images.html | 17 | ||||
-rw-r--r-- | themes/default/layouts/partials/generate-feeds.html | 2 |
2 files changed, 11 insertions, 8 deletions
diff --git a/themes/default/layouts/partials/function-caches-images.html b/themes/default/layouts/partials/function-caches-images.html index 145f5e3..c8d094d 100644 --- a/themes/default/layouts/partials/function-caches-images.html +++ b/themes/default/layouts/partials/function-caches-images.html @@ -1,13 +1,16 @@ {{- $data := slice -}} {{- $source := .Source -}} {{- $dimensions := or .Dimensions "300x300" -}} -{{- $directory := or .Directory "/" -}} +{{- $target := or .Target "/" -}} {{- $copy := .Copy -}} +{{- $directory := path.Dir $copy -}} +{{- $basename := path.BaseName $copy -}} {{- $type := strings.TrimPrefix "." (path.Ext $copy) -}} -{{- $cached := fileExists (print "public/" $copy) -}} +{{- $optimized := print $directory "/" $basename ".webp" -}} +{{- $cached := and (fileExists (print "public/" $copy)) (fileExists (print "public/" $optimized)) -}} {{- with $404image := resources.Get "data/media/404.png" -}} - {{- $404image = .Content | resources.FromString (print $directory (path.Base .)) -}} + {{- $404image = .Content | resources.FromString (print $target (path.Base .)) -}} {{- $data = $data | append (dict "Width" $404image.Width @@ -20,7 +23,7 @@ {{- if $cached -}} {{- with $image := resources.Get (print "public/" $copy) -}} - {{- $image = .Content | resources.FromString (print $directory (path.Base .)) -}} + {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} {{- $data = slice | append (dict "Width" $image.Width @@ -35,7 +38,7 @@ {{- with .Err -}} {{- warnf "%s" . -}} {{- else -}} - {{- $image = .Content | resources.FromString (print $directory (path.Base .)) -}} + {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} {{- $image = $image.Fit (print $dimensions " " $type) -}} {{- $image = $image | resources.Copy $copy -}} {{- @@ -46,9 +49,9 @@ "RelPermalink" $image.RelPermalink ) -}} - {{- $image = .Content | resources.FromString (print $directory (path.Base .)) -}} + {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} {{- $image = $image.Fit (print $dimensions " " "webp") -}} - {{- $image = $image | resources.Copy (print (path.Dir $copy) "/" (path.BaseName $copy) ".webp") -}} + {{- $image = $image | resources.Copy $optimized -}} {{- $writeToFile := $image.Permalink -}} {{- end -}} {{- end -}} diff --git a/themes/default/layouts/partials/generate-feeds.html b/themes/default/layouts/partials/generate-feeds.html index 69f900b..7fc6ea8 100644 --- a/themes/default/layouts/partials/generate-feeds.html +++ b/themes/default/layouts/partials/generate-feeds.html @@ -202,7 +202,7 @@ (dict "Source" $faviconDomain "Dimensions" "160x160" - "Directory" (print (partial "function-paths.html" "media") "/") + "Target" (print (partial "function-paths.html" "media") "/") "Copy" (print (partial "function-paths.html" "media") "/favicon." $domain ".png") ) -}} |