From 5c88aec0945cd5f69a7e000c34b9d36254020340 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Sat, 27 Apr 2024 16:36:22 +0100 Subject: [PATCH] feat(blox): add clearer error message --- .../layouts/partials/blox/cta-image-paragraph.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/blox-tailwind/layouts/partials/blox/cta-image-paragraph.html b/modules/blox-tailwind/layouts/partials/blox/cta-image-paragraph.html index 8bbc8bdc..fcfa7090 100644 --- a/modules/blox-tailwind/layouts/partials/blox/cta-image-paragraph.html +++ b/modules/blox-tailwind/layouts/partials/blox/cta-image-paragraph.html @@ -10,8 +10,13 @@ {{ range $idx, $item := $block.content.items }} {{ $title := .title | emojify | $page.RenderString }} {{ $text := .text | emojify | $page.RenderString }} - {{ $image := resources.GetMatch (path.Join "media" .image) }} - {{ $image = $image.Process "Resize 800x webp" }} + {{ $image_path := path.Join "media" .image }} + {{ $image := resources.GetMatch $image_path }} + {{ with $image }} + {{ $image = $image.Process "Resize 800x webp" }} + {{ else }} + {{ errorf "%s uses the `cta-image-paragraph` blox which specifies a non-existent `image` at `assets/%s`. Please add the image to this folder and try again." $page.File.Path $image_path }} + {{ end }}
{{$title | plainify}}