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/docs/rss.xml.j
2025-04-22 20:06:12 +02:00

24 lines
686 B
Plaintext

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
});
}