diff options
| author | aman333nolawz <amananudhiu@gmail.com> | 2026-03-02 21:49:13 +0530 |
|---|---|---|
| committer | aman333nolawz <amananudhiu@gmail.com> | 2026-03-02 21:49:13 +0530 |
| commit | d41eff9eccf66644c4c60f53cb516bf079937a28 (patch) | |
| tree | 248a0863a3181369f943d678ec4273911d35efac /src/pages/rss.xml.ts | |
Using astro-erudite for static site generation
Diffstat (limited to 'src/pages/rss.xml.ts')
| -rw-r--r-- | src/pages/rss.xml.ts | 25 |
1 files changed, 25 insertions, 0 deletions
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 }) + } +} |
