🐛 Fix: Reassignment of variable names

I'm not sure why this is such a big problem, but hugo doesn't seem to like this. It is also better to just use the intended way to reassign vars always.

Before, *feature* images if using background.html would always get overwritten, now that is fixed.
This commit is contained in:
Served Smart
2025-06-23 02:26:39 +02:00
parent f82776c86b
commit 80486364cd
4 changed files with 13 additions and 13 deletions
+5 -5
View File
@@ -65,14 +65,14 @@
{{ end }}
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{ range $backgroundAndFeaturedImages }}
{{ $images := slice }}
{{ $classImages := slice }}
{{ if or $disableImageOptimization (strings.HasSuffix .Name ".svg") }}
{{ $images = $images | append . }}
{{ $classImages = $classImages | append . }}
{{ else }}
{{ $images = $images | append (.Resize "600x") }}
{{ $images = $images | append (.Resize (print ($.Site.Params.backgroundImageWidth | default "1200") "x")) }}
{{ $classImages = $classImages | append (.Resize "600x") }}
{{ $classImages = $classImages | append (.Resize (print ($.Site.Params.backgroundImageWidth | default "1200") "x")) }}
{{ end }}
{{ range $images }}
{{ range $classImages }}
{{ $className := printf "background-image-%s" (md5 .RelPermalink) }}
{{ $cssBackgroundImage := printf ".%s { background-image: url(\"%s\"); }" $className .RelPermalink }}
{{ $cssBackgroundImage = $cssBackgroundImage | resources.FromString "css/background-image.css" }}