fix: handle empty/undefined images in feeds

This commit is contained in:
Ricardo
2026-01-28 17:37:42 +01:00
parent 24f790c4cb
commit 7ca7c5e464
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ eleventyExcludeFromCollections: true
"title": {{ post.data.title | default(post.content | striptags | truncate(80)) | jsonEncode | safe }}, "title": {{ post.data.title | default(post.content | striptags | truncate(80)) | jsonEncode | safe }},
"content_html": {{ post.content | htmlToAbsoluteUrls(absolutePostUrl) | jsonEncode | safe }}, "content_html": {{ post.content | htmlToAbsoluteUrls(absolutePostUrl) | jsonEncode | safe }},
"date_published": "{{ post.date | dateToRfc3339 }}" "date_published": "{{ post.date | dateToRfc3339 }}"
{%- if postImage %}, {%- if postImage and postImage != "" %},
"image": "{{ postImage | url | absoluteUrl(site.url) }}" "image": "{{ postImage | url | absoluteUrl(site.url) }}"
{%- endif %} {%- endif %}
}{% if not loop.last %},{% endif %} }{% if not loop.last %},{% endif %}
+1 -1
View File
@@ -20,7 +20,7 @@ eleventyExcludeFromCollections: true
<guid isPermaLink="true">{{ absolutePostUrl }}</guid> <guid isPermaLink="true">{{ absolutePostUrl }}</guid>
<pubDate>{{ post.date | dateToRfc822 }}</pubDate> <pubDate>{{ post.date | dateToRfc822 }}</pubDate>
<description>{{ post.content | htmlToAbsoluteUrls(absolutePostUrl) | escape }}</description> <description>{{ post.content | htmlToAbsoluteUrls(absolutePostUrl) | escape }}</description>
{%- if postImage %} {%- if postImage and postImage != "" %}
{%- set imageUrl = postImage | url | absoluteUrl(site.url) %} {%- set imageUrl = postImage | url | absoluteUrl(site.url) %}
<enclosure url="{{ imageUrl }}" type="image/jpeg" length="0"/> <enclosure url="{{ imageUrl }}" type="image/jpeg" length="0"/>
<media:content url="{{ imageUrl }}" medium="image"/> <media:content url="{{ imageUrl }}" medium="image"/>