mirror of
https://github.com/YouHaveTrouble/youhavetrouble.github.io.git
synced 2026-08-28 00:56:42 +00:00
22 lines
738 B
TypeScript
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,
|
|
})),
|
|
});
|
|
} |