summaryrefslogtreecommitdiff
path: root/src/pages/posts/feed.xml.ts
diff options
context:
space:
mode:
authorMatt Kosarek <matt.kosarek@canonical.com>2026-03-11 17:49:05 -0400
committerMatt Kosarek <matt.kosarek@canonical.com>2026-03-11 17:49:05 -0400
commit77b0f69d0c6e555349dd491d7ca209924d119e61 (patch)
tree095cf20002f5df752c04c20af4366588bd7ba32b /src/pages/posts/feed.xml.ts
parentc929a29c728c6799a3f83f5ad5c1c6f99ed516d4 (diff)
Migrate to astroHEADmaster
Diffstat (limited to 'src/pages/posts/feed.xml.ts')
-rw-r--r--src/pages/posts/feed.xml.ts21
1 files changed, 21 insertions, 0 deletions
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,
+ })),
+ });
+}