From d7b8cdd1530233604bb0d5bb97209eb214d05cbd Mon Sep 17 00:00:00 2001 From: Joe Carstairs <65492573+Sycamost@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:44:18 +0100 Subject: [PATCH] Adds RSS feed for links --- website/src/pages/links/rss.xml.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 website/src/pages/links/rss.xml.ts diff --git a/website/src/pages/links/rss.xml.ts b/website/src/pages/links/rss.xml.ts new file mode 100644 index 0000000..009588a --- /dev/null +++ b/website/src/pages/links/rss.xml.ts @@ -0,0 +1,27 @@ +import rss from '@astrojs/rss'; +import type { APIContext } from 'astro'; +import LINKS from '../../data/links.ts'; + +export async function GET(context: APIContext) { + // `site` is guaranteed to exist because we define it in our Astro config + const site = context.site!; + + return rss({ + title: 'Joe Carstairs’ links', + description: 'An assortment of links I’m accumulating.', + customData: ` + /images/headshot.webp + en-GB + `, + site, + trailingSlash: false, + items: LINKS.map((link) => ({ + link: link.href, + title: link.title, + content: link.description, + pubDate: new Date(link.isoDateAdded), + description: link.description, + author: 'Joe Carstairs', + })), + }) +}