import rss from '@astrojs/rss'; import { getCollection } from 'astro:content'; import { SITE } from '../config'; export async function GET(context) { const posts = (await getCollection('posts', ({ data }) => !data.draft && data.lang === 'en')) .sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()); return rss({ title: SITE.name, description: SITE.description, site: context.site, items: posts.map((post) => ({ title: post.data.title, description: post.data.description, pubDate: post.data.pubDate, link: `/posts/${post.slug}/`, categories: [post.data.category, ...post.data.tags], })), customData: `${SITE.locale}`, }); }