From 1ae1f6f042661b4a8ac1ee2547a0aa80dd2e4e64 Mon Sep 17 00:00:00 2001 From: Adam Sedwick Date: Mon, 16 Oct 2023 16:55:51 -0500 Subject: [PATCH] add rss feed --- .eleventy.js | 2 ++ package-lock.json | 27 +++++++++++++++++++++++++++ package.json | 1 + src/feed.njk | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 src/feed.njk diff --git a/.eleventy.js b/.eleventy.js index b66766b..359d0cb 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -4,6 +4,7 @@ const Image = require("@11ty/eleventy-img"); const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight"); const filters = require("./src/assets/filters.js"); const tag_aliases = require("./src/data/tag_aliases.json"); +const pluginRss = require("@11ty/eleventy-plugin-rss"); async function imageShortcode(src, alt, sizes) { let metadata = await Image(src, { @@ -63,6 +64,7 @@ module.exports = function(eleventyConfig) { eleventyConfig.addPlugin(syntaxHighlight); eleventyConfig.addPlugin(emojiReadTime, { showEmoji: false }); + eleventyConfig.addPlugin(pluginRss); eleventyConfig.addWatchTarget("./src/sass/"); diff --git a/package-lock.json b/package-lock.json index 8f090f5..4f7e612 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ }, "devDependencies": { "@11ty/eleventy": "^2.0.1", + "@11ty/eleventy-plugin-rss": "^1.2.0", "@11ty/eleventy-plugin-syntaxhighlight": "^3.0.6" } }, @@ -203,6 +204,21 @@ "node": ">= 10.0.0" } }, + "node_modules/@11ty/eleventy-plugin-rss": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-rss/-/eleventy-plugin-rss-1.2.0.tgz", + "integrity": "sha512-YzFnSH/5pObcFnqZ2sAQ782WmpOZHj1+xB9ydY/0j7BZ2jUNahn53VmwCB/sBRwXA/Fbwwj90q1MLo01Ru0UaQ==", + "dev": true, + "dependencies": { + "debug": "^4.3.4", + "posthtml": "^0.16.6", + "posthtml-urls": "1.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/11ty" + } + }, "node_modules/@11ty/eleventy-plugin-syntaxhighlight": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-syntaxhighlight/-/eleventy-plugin-syntaxhighlight-3.0.6.tgz", @@ -4870,6 +4886,17 @@ } } }, + "@11ty/eleventy-plugin-rss": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-rss/-/eleventy-plugin-rss-1.2.0.tgz", + "integrity": "sha512-YzFnSH/5pObcFnqZ2sAQ782WmpOZHj1+xB9ydY/0j7BZ2jUNahn53VmwCB/sBRwXA/Fbwwj90q1MLo01Ru0UaQ==", + "dev": true, + "requires": { + "debug": "^4.3.4", + "posthtml": "^0.16.6", + "posthtml-urls": "1.0.0" + } + }, "@11ty/eleventy-plugin-syntaxhighlight": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-syntaxhighlight/-/eleventy-plugin-syntaxhighlight-3.0.6.tgz", diff --git a/package.json b/package.json index 20679d7..2758cc6 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "license": "ISC", "devDependencies": { "@11ty/eleventy": "^2.0.1", + "@11ty/eleventy-plugin-rss": "^1.2.0", "@11ty/eleventy-plugin-syntaxhighlight": "^3.0.6" }, "dependencies": { diff --git a/src/feed.njk b/src/feed.njk new file mode 100644 index 0000000..d1f6bd3 --- /dev/null +++ b/src/feed.njk @@ -0,0 +1,38 @@ +---json +{ + "permalink": "feed.xml", + "eleventyExcludeFromCollections": true, + "metadata": { + "title": "Blind3y3Design Posts", + "language": "en", + "url": "https://www.blind3y3design.com/", + "author": { + "name": "Adam Sedwick", + "email": "adam.sedwick@gmail.com" + } + } +} +--- + + + {{ metadata.title }} + {{ metadata.subtitle }} + + + {{ collections.posts | getNewestCollectionItemDate | dateToRfc3339 }} + {{ metadata.url }} + + {{ metadata.author.name }} + {{ metadata.author.email }} + + {%- for post in collections.posts | reverse %} + {%- set absolutePostUrl = post.url | absoluteUrl(metadata.url) %} + + {{ post.data.title }} + + {{ post.date | dateToRfc3339 }} + {{ absolutePostUrl }} + {{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) }} + + {%- endfor %} + \ No newline at end of file