This repository has been archived on 2025-12-24. You can view files and clone it, but cannot push or open issues or pull requests.
site-template/src/pages/rss.xml.js
2025-03-07 14:59:06 +01:00

24 lines
686 B
JavaScript

import rss from '@astrojs/rss';
import { getCollection } from 'astro:content'
import sanitizeHtml from 'sanitize-html';
import MarkdownIt from 'markdown-it';
const parser = new MarkdownIt()
import { RSS_CONFIG } from '../app/config'
export async function GET(context) {
const blog = await getCollection('posts')
const store = await getCollection('store')
const all = [ ...blog ]
return rss({
site: context.site,
items: all.map((post) => ({
link: `/blog/${post.id}/`,
content: sanitizeHtml(parser.render(post.body), {
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img'])
}),
...post.data,
})),
...RSS_CONFIG
});
}