From b188edd2ee2089cd01d702a0da558d7b662a66f2 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Wed, 28 Jan 2026 17:58:29 +0100 Subject: [PATCH] fix: handle photo array in base.njk OpenGraph/Twitter meta The photo property can be an array for multi-photo posts. Normalize photo to first element if array, and avoid startsWith on non-strings. Co-Authored-By: Claude Opus 4.5 --- _includes/layouts/base.njk | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/_includes/layouts/base.njk b/_includes/layouts/base.njk index ad34938..d69d58a 100644 --- a/_includes/layouts/base.njk +++ b/_includes/layouts/base.njk @@ -9,18 +9,25 @@ {% set ogTitle = title | default(site.name) %} {% set ogDesc = description | default(content | ogDescription(200)) | default(site.description) %} {% set contentImage = content | extractFirstImage %} + {# Normalize photo - could be array for multi-photo posts #} + {% set ogPhoto = photo %} + {% if ogPhoto %} + {% if ogPhoto[0] and (ogPhoto[0] | length) > 10 %} + {% set ogPhoto = ogPhoto[0] %} + {% endif %} + {% endif %} - {% if photo %} - - {% elif image %} - - {% elif contentImage %} - + {% if ogPhoto and ogPhoto != "" and (ogPhoto | length) > 10 %} + + {% elif image and image != "" and (image | length) > 10 %} + + {% elif contentImage and contentImage != "" and (contentImage | length) > 10 %} + {% else %} {% endif %} @@ -29,16 +36,16 @@ {# Twitter Card meta tags #} - {% set hasImage = photo or image or contentImage %} + {% set hasImage = (ogPhoto and ogPhoto != "" and (ogPhoto | length) > 10) or (image and image != "" and (image | length) > 10) or (contentImage and contentImage != "" and (contentImage | length) > 10) %} - {% if photo %} - - {% elif image %} - - {% elif contentImage %} - + {% if ogPhoto and ogPhoto != "" and (ogPhoto | length) > 10 %} + + {% elif image and image != "" and (image | length) > 10 %} + + {% elif contentImage and contentImage != "" and (contentImage | length) > 10 %} + {% endif %} {# Favicon #}