1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-10-23 15:04:26 -04:00

make optimize-image more function-like

....instead of relying on $.Scratch
This commit is contained in:
2020-01-15 10:30:01 -05:00
parent 827ffd20e3
commit f51e912632
7 changed files with 48 additions and 46 deletions

View File

@@ -1,12 +1,12 @@
{{- /* Default image */ -}}
{{/* Default image */}}
{{- $defaultImagePath := (path.Join "content" $.Site.Params.defaultimage) }}
{{- $.Scratch.Set "defaultImage_url" (replace $defaultImagePath "content/" $.Site.BaseURL) }}
{{- with (imageConfig $defaultImagePath) }}
{{ $.Scratch.Set "defaultImage_url" (replace $defaultImagePath "content/" $.Site.BaseURL) }}
{{ with (imageConfig $defaultImagePath) }}
{{- $.Scratch.Set "defaultImage_width" .Width }}
{{- $.Scratch.Set "defaultImage_height" .Height }}
{{- end }}
{{ end -}}
{{- /* Article image (with fallback to default image */ -}}
{{/* Article image (with fallback to default image */}}
{{- with .Params.image }}
{{- $imagePath := (path.Join "content" $.File.Dir "images/" .) }}
@@ -15,18 +15,18 @@
{{- $.Scratch.Set "socialImage_width" .Width }}
{{- $.Scratch.Set "socialImage_height" .Height }}
{{- end }}
{{- else }}
{{ else }}
{{- $.Scratch.Set "socialImage_url" (replace $defaultImagePath "content/" $.Site.BaseURL) }}
{{- with (imageConfig $defaultImagePath) }}
{{- $.Scratch.Set "socialImage_width" .Width }}
{{- $.Scratch.Set "socialImage_height" .Height }}
{{- end }}
{{- end }}
{{ end -}}
{{- /* Site logo */ -}}
{{/* Site logo */}}
{{- $logoImagePath := (path.Join "content" "logo.png") }}
{{- $.Scratch.Set "logoImage_url" (replace $logoImagePath "content/" $.Site.BaseURL) }}
{{- with (imageConfig $logoImagePath) }}
{{ $.Scratch.Set "logoImage_url" (replace $logoImagePath "content/" $.Site.BaseURL) }}
{{ with (imageConfig $logoImagePath) }}
{{- $.Scratch.Set "logoImage_width" .Width }}
{{- $.Scratch.Set "logoImage_height" .Height }}
{{- end }}
{{ end -}}