From 547b07f10e308276ca875aefbf40ec2a6ffc4372 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sun, 15 Sep 2024 22:08:28 -0600 Subject: properly handle unlisted posts in RSS --- eleventy.config.js | 20 ++------------------ feed.njk | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 feed.njk diff --git a/eleventy.config.js b/eleventy.config.js index 0b839ca..f187c91 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -1,5 +1,5 @@ import { InputPathToUrlTransformPlugin } from "@11ty/eleventy"; -import { feedPlugin } from "@11ty/eleventy-plugin-rss"; +import pluginRss from "@11ty/eleventy-plugin-rss"; import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight"; import anchor from "markdown-it-anchor"; @@ -62,23 +62,7 @@ export default function (eleventyConfig) { Prism.languages.text = {}; }, }); - eleventyConfig.addPlugin(feedPlugin, { - type: "atom", - outputPath: "/feed.xml", - collection: { - name: "post", - limit: 0, - }, - metadata: { - language: "en", - title: "boringcactus", - subtitle: "boringcactus’s blog posts", - base: "https://www.boringcactus.com/", - author: { - name: "boringcactus / Melody Horn", - }, - }, - }); + eleventyConfig.addPlugin(pluginRss); eleventyConfig.amendLibrary("md", (mdLib) => mdLib.use(anchor)); diff --git a/feed.njk b/feed.njk new file mode 100644 index 0000000..28bec07 --- /dev/null +++ b/feed.njk @@ -0,0 +1,39 @@ +---json +{ + "permalink": "feed.xml", + "eleventyExcludeFromCollections": true, + "metadata": { + "language": "en", + "title": "boringcactus", + "subtitle": "boringcactus’s blog posts", + "base": "https://www.boringcactus.com/", + "author": { + "name": "boringcactus / Melody Horn" + } + } +} +--- + + + {{ metadata.title }} + {{ metadata.description }} + + + {{ collections.post | getNewestCollectionItemDate | dateToRfc3339 }} + {{ metadata.base | addPathPrefixToFullUrl }} + + {{ metadata.author.name }} + + {%- for post in collections.post | reverse %} + {%- if not post.data.unlisted %} + {%- set absolutePostUrl %}{{ post.url | htmlBaseUrl(metadata.base) }}{% endset %} + + {{ post.data.title }} + + {{ post.date | dateToRfc3339 }} + {{ absolutePostUrl }} + {{ post.content | renderTransforms(post.data.page, metadata.base) }} + + {%- endif %} + {%- endfor %} + -- cgit v1.2.3