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 #}