From 8a32c3bf0cfdda8b0d44794a48400a98783f2266 Mon Sep 17 00:00:00 2001 From: Sindre Kjelsrud Date: Sun, 10 Dec 2023 02:28:43 +0100 Subject: [PATCH] :sparkles: added RSS to site --- src/pages/rss.xml.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/pages/rss.xml.js diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js new file mode 100644 index 0000000..811cc42 --- /dev/null +++ b/src/pages/rss.xml.js @@ -0,0 +1,18 @@ +import rss from '@astrojs/rss'; +import { getCollection } from 'astro:content'; + +export async function GET(context) { + const blog = await getCollection('blog'); + return rss({ + title: 'Sindre Kjelsrud', + description: 'Recent content on Sindre Kjelsrud`s blog', + site: context.site, + items: blog.map((post) => ({ + title: post.data.title, + pubDate: post.data.pubDate, + description: post.data.description, + customData: post.data.customData, + link: `/blog/${post.slug}/`, + })), + }); +} \ No newline at end of file