Files for my website bwc9876.dev
0
fork

Configure Feed

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

at 91734c71dccbb76dcc2a4b8aefc2b52047b5f953 27 lines 916 B view raw
1import rss from "@astrojs/rss"; 2import { getCollection } from "astro:content"; 3import sanitizeHtml from "sanitize-html"; 4import MarkdownIt from "markdown-it"; 5const parser = new MarkdownIt(); 6 7export async function GET(context: { site: string | URL }) { 8 const blogEntries = await getCollection("posts"); 9 10 blogEntries.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf()); 11 12 return rss({ 13 title: "Ben C's Blog", 14 description: "Talking about web development, NixOS, Linux customization, and more", 15 site: context.site, 16 items: blogEntries.map((post) => ({ 17 title: post.data.title, 18 pubDate: post.data.date, 19 description: post.data.summary, 20 link: `/blog/posts/${post.slug}`, 21 content: sanitizeHtml(parser.render(post.body), { 22 allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]) 23 }) 24 })), 25 customData: `<language>en-us</language>` 26 }); 27}