From d41eff9eccf66644c4c60f53cb516bf079937a28 Mon Sep 17 00:00:00 2001 From: aman333nolawz Date: Mon, 2 Mar 2026 21:49:13 +0530 Subject: Using astro-erudite for static site generation --- src/pages/rss.xml.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/pages/rss.xml.ts (limited to 'src/pages/rss.xml.ts') diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts new file mode 100644 index 0000000..fe7e9d2 --- /dev/null +++ b/src/pages/rss.xml.ts @@ -0,0 +1,25 @@ +import { SITE } from '@/consts' +import rss from '@astrojs/rss' +import type { APIContext } from 'astro' +import { getAllPosts } from '@/lib/data-utils' + +export async function GET(context: APIContext) { + try { + const posts = await getAllPosts() + + return rss({ + title: SITE.title, + description: SITE.description, + site: context.site ?? SITE.href, + items: posts.map((post) => ({ + title: post.data.title, + description: post.data.description, + pubDate: post.data.date, + link: `/blog/${post.id}/`, + })), + }) + } catch (error) { + console.error('Error generating RSS feed:', error) + return new Response('Error generating RSS feed', { status: 500 }) + } +} -- cgit v1.2.3