diff options
-rw-r--r-- | themes/default/layouts/partials/function-caches-images.html | 58 | ||||
-rw-r--r-- | themes/default/layouts/partials/generate-feeds.html | 2 |
2 files changed, 36 insertions, 24 deletions
diff --git a/themes/default/layouts/partials/function-caches-images.html b/themes/default/layouts/partials/function-caches-images.html index 9a18f7b..d21e72a 100644 --- a/themes/default/layouts/partials/function-caches-images.html +++ b/themes/default/layouts/partials/function-caches-images.html @@ -1,20 +1,22 @@ -{{- $data := slice -}} -{{- $source := .Source -}} -{{- $dimensions := or .Dimensions "300x300" -}} -{{- $target := or .Target "/" -}} -{{- $copy := .Copy -}} -{{- $directory := path.Dir $copy -}} -{{- $basename := path.BaseName $copy -}} -{{- $type := strings.TrimPrefix "." (path.Ext $copy) -}} -{{- $optimized := print $directory "/" $basename ".webp" -}} -{{- $cached := and (fileExists (print "public/" $copy)) (fileExists (print "public/" $optimized)) -}} -{{- $local := print "public/" $source -}} -{{- $localized := fileExists $local -}} +{{- $data := dict -}} +{{- $source := .Source -}} +{{- $fit := .Fit -}} +{{- $resize := .Resize -}} +{{- $target := or .Target "/" -}} +{{- $copy := .Copy -}} +{{- $directory := path.Dir $copy -}} +{{- $basename := path.BaseName $copy -}} +{{- $type := strings.TrimPrefix "." (path.Ext $copy) -}} +{{- $optimized := or .OptimizedCopy (print $directory "/" $basename ".webp") -}} +{{- $optimizedType := strings.TrimPrefix "." (path.Ext $optimized) -}} +{{- $cached := and (fileExists (print "public/" $copy)) (fileExists (print "public/" $optimized)) -}} +{{- $local := print "public/" $source -}} +{{- $localized := fileExists $local -}} {{- with $404image := resources.Get "data/media/404.png" -}} {{- $404image = .Content | resources.FromString (print $target (path.Base .)) -}} {{- - $data = $data | append (dict + $data = (dict "Width" $404image.Width "Height" $404image.Height "Permalink" $404image.Permalink @@ -27,7 +29,7 @@ {{- with $image := resources.Get (print "public/" $copy) -}} {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} {{- - $data = slice | append (dict + $data = (dict "Width" $image.Width "Height" $image.Height "Permalink" $image.Permalink @@ -44,10 +46,10 @@ {{- $type := strings.TrimPrefix "." (path.Ext $local) -}} {{- with $image := resources.Get $local -}} {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} - {{- $image = $image.Fit (print $dimensions " " $type) -}} + {{- $image = $image.Fit (print $fit " " $type) -}} {{- $image = $image | resources.Copy $copy -}} {{- - $data = slice | append (dict + $data = (dict "Width" $image.Width "Height" $image.Height "Permalink" $image.Permalink @@ -55,17 +57,22 @@ ) -}} {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} - {{- $image = $image.Fit (print $dimensions " " "webp") -}} + {{- $image = $image.Fit (print $fit " " $optimizedType) -}} {{- $image = $image | resources.Copy $optimized -}} - {{- $writeToFile := $image.Permalink -}} + {{- + $data = merge $data (dict + "OptPermalink" $image.Permalink + "OptRelPermalink" $image.RelPermalink + ) + -}} {{- end -}} {{- end -}} {{- else -}} {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} - {{- $image = $image.Fit (print $dimensions " " $type) -}} + {{- $image = $image.Fit (print $fit " " $type) -}} {{- $image = $image | resources.Copy $copy -}} {{- - $data = slice | append (dict + $data = (dict "Width" $image.Width "Height" $image.Height "Permalink" $image.Permalink @@ -73,11 +80,16 @@ ) -}} {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} - {{- $image = $image.Fit (print $dimensions " " "webp") -}} + {{- $image = $image.Fit (print $fit " " $optimizedType) -}} {{- $image = $image | resources.Copy $optimized -}} - {{- $writeToFile := $image.Permalink -}} + {{- + $data = merge $data (dict + "OptPermalink" $image.Permalink + "OptRelPermalink" $image.RelPermalink + ) + -}} {{- end -}} {{- end -}} {{- end -}} -{{- return (index $data 0) -}} +{{- return $data -}} diff --git a/themes/default/layouts/partials/generate-feeds.html b/themes/default/layouts/partials/generate-feeds.html index 7fc6ea8..1cdc998 100644 --- a/themes/default/layouts/partials/generate-feeds.html +++ b/themes/default/layouts/partials/generate-feeds.html @@ -201,7 +201,7 @@ {{- $imageSource := partial "function-caches-images.html" (dict "Source" $faviconDomain - "Dimensions" "160x160" + "Fit" "160x160" "Target" (print (partial "function-paths.html" "media") "/") "Copy" (print (partial "function-paths.html" "media") "/favicon." $domain ".png") ) |