trying to pin down my thoughts here
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 30 lines 803 B view raw
1import rss from "@astrojs/rss"; 2import { getCollection } from "astro:content"; 3import { HOME } from "@consts"; 4 5type Context = { 6 site: string 7} 8 9export async function GET(context: Context) { 10 const blog = (await getCollection("blog")) 11 .filter(post => !post.data.draft); 12 13 const projects = (await getCollection("projects")) 14 .filter(project => !project.data.draft); 15 16 const items = [...blog, ...projects] 17 .sort((a, b) => new Date(b.data.date).valueOf() - new Date(a.data.date).valueOf()); 18 19 return rss({ 20 title: HOME.TITLE, 21 description: HOME.DESCRIPTION, 22 site: context.site, 23 items: items.map((item) => ({ 24 title: item.data.title, 25 description: item.data.description, 26 pubDate: item.data.date, 27 link: `/${item.collection}/${item.slug}/`, 28 })), 29 }); 30}