Files
youhavetrouble.github.io/src/pages/rss.xml.ts
T
2026-08-09 09:25:13 +02:00

22 lines
738 B
TypeScript

import rss from '@astrojs/rss';
import sanitizeHtml from 'sanitize-html';
import { marked } from 'marked';
import {getCollection} from "astro:content";
export async function GET(context: { site: any; }) {
const posts = await getCollection('posts');
return rss({
title: 'YouHaveBlog',
description: 'Something that\'s supposed to be thoughts.',
site: context.site,
items: posts.map((post) => ({
link: `/blog/${post.id}/`,
content: sanitizeHtml(marked.parse(post.body ?? ""), {
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img'])
}),
pubDate: new Date(post.data.publishDate),
...post.data,
})),
});
}