SanYeCao-blog/src/pages/rss.xml.js

20 lines
696 B
JavaScript
Raw Normal View History

2026-03-24 18:09:42 +00:00
import rss from '@astrojs/rss';
import { pagesGlobToRssItems } from '@astrojs/rss';
import { getCollection } from 'astro:content';
2026-03-24 18:01:45 +00:00
export async function GET(context) {
2026-03-24 18:09:42 +00:00
const posts = await getCollection("blog");
2026-03-24 18:01:45 +00:00
return rss({
title: 'Astro Learner | Blog',
description: 'My journey learning Astro',
site: context.site,
items: await pagesGlobToRssItems(import.meta.glob('./**/*.md')),
2026-03-24 18:09:42 +00:00
items: posts.map((post) => ({
title: post.data.title,
pubDate: post.data.pubDate,
description: post.data.description,
link: `/posts/${post.id}/`,
})),
2026-03-24 18:01:45 +00:00
customData: `<language>en-us</language>`,
2026-03-24 18:09:42 +00:00
})
2026-03-24 18:01:45 +00:00
}