From 77b0f69d0c6e555349dd491d7ca209924d119e61 Mon Sep 17 00:00:00 2001 From: Matt Kosarek Date: Wed, 11 Mar 2026 17:49:05 -0400 Subject: Migrate to astro --- src/pages/posts/feed.xml.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/pages/posts/feed.xml.ts (limited to 'src/pages/posts/feed.xml.ts') diff --git a/src/pages/posts/feed.xml.ts b/src/pages/posts/feed.xml.ts new file mode 100644 index 0000000..43b9b84 --- /dev/null +++ b/src/pages/posts/feed.xml.ts @@ -0,0 +1,21 @@ +import rss from '@astrojs/rss'; +import { getCollection } from 'astro:content'; +import { marked } from 'marked'; +import type { APIContext } from 'astro'; + +export async function GET(context: APIContext) { + const posts = await getCollection('posts'); + posts.sort((a, b) => b.data.date.localeCompare(a.data.date)); + + return rss({ + title: "Matthew Kosarek's Blog", + description: 'Updates and thoughts from Matthew Kosarek', + site: context.site ?? 'https://matthewkosarek.xyz', + items: posts.map(post => ({ + title: post.data.title, + pubDate: new Date(post.data.date), + link: `/posts/${post.slug}/`, + content: marked(post.body) as string, + })), + }); +} -- cgit v1.2.1