From 1607d31bebc9514257d5cd7b8c58cdd9c1d41c79 Mon Sep 17 00:00:00 2001 From: Sebin Nyshkim Date: Sun, 20 Apr 2025 22:30:14 +0200 Subject: [PATCH] build: :wrench: use manual feed template instead of virtual one In order to display the title image in the feed.xml like in the posts on the website, a more customizable variant is needed. --- eleventy.config.js | 21 ++------------------- src/feed.njk | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 src/feed.njk diff --git a/eleventy.config.js b/eleventy.config.js index 72d8183..f05c8e3 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -1,7 +1,6 @@ import fs from 'node:fs'; import { env } from 'node:process'; import { eleventyImageTransformPlugin } from '@11ty/eleventy-img'; -import { feedPlugin } from '@11ty/eleventy-plugin-rss'; import Image from '@11ty/eleventy-img'; import eleventyPluginCiu from '@alexcarpenter/eleventy-plugin-caniuse'; import eleventyPluginEmbedEverything from 'eleventy-plugin-embed-everything'; @@ -12,6 +11,7 @@ import eleventyPluginNavigation from '@11ty/eleventy-navigation'; import eleventyPluginOgImage from 'eleventy-plugin-og-image'; import eleventyPluginReadingTime from '@myxotod/eleventy-plugin-readingtime'; import eleventyPluginRobotsTxt from 'eleventy-plugin-robotstxt'; +import eleventyPluginRss from '@11ty/eleventy-plugin-rss'; import eleventyPluginSyntaxHighlight from '@11ty/eleventy-plugin-syntaxhighlight'; import markdownIt from 'markdown-it'; import markdownItAbbr from 'markdown-it-abbr'; @@ -111,24 +111,7 @@ export default async function (eleventyConfig) { sizes: '(min-width: 1280px) 960px, (min-width: 1024px) 768px, (min-width: 640px) 640px, 480px' } }); - eleventyConfig.addPlugin(feedPlugin, { - type: 'atom', // or "rss", "json" - outputPath: '/feed.xml', - collection: { - name: 'posts', // iterate over `collections.posts` - limit: 0 // 0 means no limit - }, - metadata: { - language: 'en', - title: "Sebin's Blog", - subtitle: 'Writing about stuff I have vague interests in and commenting on stuff I read.', - base: 'https://blog.sebin-nyshkim.net/', - author: { - name: 'Sebin Nyshkim', - email: '' // Optional - } - } - }); + eleventyConfig.addPlugin(eleventyPluginRss); eleventyConfig.setLibrary('md', markdownIt(MARKDOWNIT_OPTIONS)); diff --git a/src/feed.njk b/src/feed.njk new file mode 100644 index 0000000..4145699 --- /dev/null +++ b/src/feed.njk @@ -0,0 +1,40 @@ +---json +{ + "permalink": "feed.xml", + "eleventyExcludeFromCollections": true, + "metadata": { + "title": "Sebin's Blog", + "description": "Writing about stuff I have vague interests in and commenting on stuff I read.", + "language": "en", + "base": "https://blog.sebin-nyshkim.net/", + "author": { + "name": "Sebin Nyshkim" + } + } +} +--- + + + {{ metadata.title }} + {{ metadata.description }} + + + {{ collections.posts | getNewestCollectionItemDate | dateToRfc3339 }} + {{ metadata.base | addPathPrefixToFullUrl }} + + {{ metadata.author.name }} + + {%- for post in collections.posts | reverse %} + {%- set absolutePostUrl %}{{ post.url | htmlBaseUrl(metadata.base) }}{% endset %} + + {{ post.data.title }} + + {{ post.date | dateToRfc3339 }} + {{ absolutePostUrl }} + + <img src="{{ post.data.image.src }}.webp?width=1200" alt="{{ post.data.image.alt }}"> + {{ post.content | renderTransforms(post.data.page, metadata.base) }} + + + {%- endfor %} +