Files
indiekit-blog/feed.njk
Ricardo 538e94f582 fix: declare collection dependencies for incremental builds
Add eleventyImport.collections to templates that access collections
via Nunjucks loops (not pagination frontmatter). Without this,
Eleventy's --incremental mode skips these pages when content changes.

- index.njk: posts, feed (homepage recent posts widget)
- feed.njk: feed (RSS must update with new posts)
- feed-json.njk: feed (JSON feed must update with new posts)
- slashes.njk: pages (slash pages index)
- categories-index.njk: categories (categories index)
2026-02-18 14:42:02 +01:00

45 lines
1.9 KiB
Plaintext

---
permalink: /feed.xml
eleventyExcludeFromCollections: true
eleventyImport:
collections:
- feed
---
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>{{ site.name }}</title>
<link>{{ site.url }}/</link>
<description>{{ site.description }}</description>
<language>{{ site.locale | default('en') }}</language>
<atom:link href="{{ site.url }}/feed.xml" rel="self" type="application/rss+xml"/>
<atom:link href="https://websubhub.com/hub" rel="hub"/>
<lastBuildDate>{{ collections.feed | getNewestCollectionItemDate | dateToRfc822 }}</lastBuildDate>
{%- for post in collections.feed %}
{%- set absolutePostUrl = site.url + post.url %}
{%- set postImage = post.data.photo %}
{%- if postImage %}
{# If photo is an array, use first element (check if first element looks like a URL) #}
{%- if postImage[0] and (postImage[0] | length) > 10 %}
{%- set postImage = postImage[0] %}
{%- endif %}
{%- endif %}
{%- if not postImage or postImage == "" %}
{%- set postImage = post.data.image or (post.content | extractFirstImage) %}
{%- endif %}
<item>
<title>{{ post.data.title | default(post.content | striptags | truncate(80)) | escape }}</title>
<link>{{ absolutePostUrl }}</link>
<guid isPermaLink="true">{{ absolutePostUrl }}</guid>
<pubDate>{{ post.date | dateToRfc822 }}</pubDate>
<description>{{ post.content | htmlToAbsoluteUrls(absolutePostUrl) | escape }}</description>
{%- if postImage and postImage != "" and (postImage | length) > 10 %}
{%- set imageUrl = postImage | url | absoluteUrl(site.url) %}
<enclosure url="{{ imageUrl }}" type="image/jpeg" length="0"/>
<media:content url="{{ imageUrl }}" medium="image"/>
{%- endif %}
</item>
{%- endfor %}
</channel>
</rss>