From d9a3c4b4a1696d564e371997ff38c935afa909d0 Mon Sep 17 00:00:00 2001 From: Nikolaos Karaolidis Date: Sat, 13 Sep 2025 23:23:17 +0000 Subject: [PATCH] Fix crash on missing hero Signed-off-by: Nikolaos Karaolidis --- layouts/partials/components/hero/index.html | 16 +++--- layouts/partials/gallery/list.html | 54 +++++++++++---------- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/layouts/partials/components/hero/index.html b/layouts/partials/components/hero/index.html index a933baf..3033fd5 100644 --- a/layouts/partials/components/hero/index.html +++ b/layouts/partials/components/hero/index.html @@ -3,13 +3,15 @@ {{ partial "components/meta/index.html" . }} {{ $hero := partial "components/hero/process.html" .Params.hero }} - {{ $data := partial "components/image/process.html" (dict "page" .Page "src" $hero.src) }} + {{ if $hero.src }} + {{ $data := partial "components/image/process.html" (dict "page" .Page "src" $hero.src) }} - {{ $final := merge $data $hero }} - {{ if $hero.exif }} - {{ $caption := partial "components/image/exif.html" $data.original }} - {{ $final = merge $final (dict "caption" $caption) }} + {{ $final := merge $data $hero }} + {{ if $hero.exif }} + {{ $caption := partial "components/image/exif.html" $data.original }} + {{ $final = merge $final (dict "caption" $caption) }} + {{ end }} + + {{ partial "components/image/index.html" $final }} {{ end }} - - {{ partial "components/image/index.html" $final }} diff --git a/layouts/partials/gallery/list.html b/layouts/partials/gallery/list.html index f45e867..1c518e3 100644 --- a/layouts/partials/gallery/list.html +++ b/layouts/partials/gallery/list.html @@ -3,37 +3,39 @@ {{ range sort .Pages "Date" "desc" }} {{ if not .Params.private }} {{ $hero := partial "components/hero/process.html" .Params.hero }} - {{ $data := partial "components/image/process.html" (dict "page" . "src" $hero.src) }} + {{ if $hero.src }} + {{ $data := partial "components/image/process.html" (dict "page" . "src" $hero.src) }} - {{- $caption := .Title -}} - {{- $title := $hero.title | default $caption | plainify -}} - {{- $alt := $hero.alt | default $title | plainify -}} + {{- $caption := .Title -}} + {{- $title := $hero.title | default $caption | plainify -}} + {{- $alt := $hero.alt | default $title | plainify -}} -
- - - -
-
- {{ $caption }} - {{ partial "components/meta/index.html" . }} +
+ + + +
+
+ {{ $caption }} + {{ partial "components/meta/index.html" . }} +
-
+ {{ end }} {{ end }} {{ end }}