From ae628ae4287fb74830bc1afbf8eee4aa6cc4f965 Mon Sep 17 00:00:00 2001 From: Joseph Montanaro Date: Sat, 22 Aug 2026 08:25:20 -0400 Subject: [PATCH] add RSS feed --- bun.lock | 2 +- package.json | 2 +- src/pages/feed.js | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/pages/feed.js diff --git a/bun.lock b/bun.lock index c66d449..0319e90 100644 --- a/bun.lock +++ b/bun.lock @@ -6,7 +6,7 @@ "dependencies": { "@astrojs/check": "0.9.10", "@astrojs/mdx": "7.0.7", - "@astrojs/rss": "4.0.19", + "@astrojs/rss": "^4.0.19", "@astrojs/sitemap": "3.7.3", "@astrojs/vue": "7.0.2", "@fontsource-variable/baskervville": "^5.2.3", diff --git a/package.json b/package.json index 411eea8..3cbd421 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "dependencies": { "@astrojs/check": "0.9.10", "@astrojs/mdx": "7.0.7", - "@astrojs/rss": "4.0.19", + "@astrojs/rss": "^4.0.19", "@astrojs/sitemap": "3.7.3", "@astrojs/vue": "7.0.2", "@fontsource-variable/baskervville": "^5.2.3", diff --git a/src/pages/feed.js b/src/pages/feed.js new file mode 100644 index 0000000..a95b3c3 --- /dev/null +++ b/src/pages/feed.js @@ -0,0 +1,25 @@ +import rss from '@astrojs/rss'; + +import { render } from 'astro:content'; +import { listPosts } from '@lib/content.ts'; + + +export async function GET(context) { + const entries = await listPosts(); + const items = await Promise.all(entries.map(async entry => { + const { remarkPluginFrontmatter } = await render(entry); + return { + title: entry.data.title, + description: remarkPluginFrontmatter.description, + link: `https://blog.jfmonty2.com/${entry.id}`, + pubDate: entry.data.date, + }; + })); + + return rss({ + title: "Joe's Blog", + description: 'I write about stuff.', + site: 'https://blog.jfmonty2.com', + items, + }); +}