From 3ee58f4e179447a5ecb0de5161666225af71b045 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 10 Apr 2026 14:43:20 +0000 Subject: [PATCH] Add blog-specific RSS feed at /blog/feed Creates a blogPosts collection filtered to posts/blog/ directory and an Atom feed template at blog/feed with the correct Content-Type header, so https://sijobling.com/blog/feed is a valid, auto-updating RSS feed. https://claude.ai/code/session_01Rzdb6FadiMnfFgKrBBDGfe --- .eleventy.js | 8 ++++++++ _headers | 3 +++ blog/feed.njk | 29 +++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 blog/feed.njk diff --git a/.eleventy.js b/.eleventy.js index 5597bec..6a92a3f 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -227,6 +227,14 @@ module.exports = function (eleventyConfig) { .sort((a, b) => a.date - b.date) .slice(-5); }); + eleventyConfig.addCollection("blogPosts", function (collectionApi) { + return collectionApi.getFilteredByTag("posts").filter((post) => { + const inputPath = post.inputPath || ""; + const normalized = inputPath.replace(/^[.\\/]*posts[\\/]/, ""); + const directory = normalized.split(/[/\\]/)[0]; + return directory === "blog"; + }); + }); eleventyConfig.addCollection("tagList", require("./_11ty/getTagList")); // Copy migrated assets from src/assets to /assets in the built site. eleventyConfig.addPassthroughCopy({ "src/assets": "assets" }); diff --git a/_headers b/_headers index 34ca8c1..82a0421 100644 --- a/_headers +++ b/_headers @@ -11,3 +11,6 @@ cache-control: public,max-age=31536000,immutable /favicon.svg cache-control: public,max-age=3600 + +/blog/feed + Content-Type: application/atom+xml; charset=UTF-8 diff --git a/blog/feed.njk b/blog/feed.njk new file mode 100644 index 0000000..cc45ec0 --- /dev/null +++ b/blog/feed.njk @@ -0,0 +1,29 @@ +--- +permalink: blog/feed +eleventyExcludeFromCollections: true +--- + + + {{ metadata.title }} - Blog + {{ metadata.feed.subtitle }} + {% set absoluteUrl %}{{ "/blog/feed" | url | absoluteUrl(metadata.url) }}{% endset %} + + + {{ collections.blogPosts | rssLastUpdatedDate }} + {{ metadata.url }}/blog/ + + {{ metadata.author.name }} + + {%- for post in collections.blogPosts %} + {% set absolutePostUrl %}{{ post.url | url | absoluteUrl(metadata.url) }}{% endset %} + + {{ post.data.title }} + + {{ post.date | rssDate }} + {{ absolutePostUrl }} + + {{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) }} + + + {%- endfor %} +