summaryrefslogtreecommitdiff
path: root/examples/blog/src/pages/rss.xml.js
blob: 3997cc45e30ea0a6a9d0740e168d25354ff0e903 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';

export async function get(context) {
	const posts = await getCollection('blog');
	return rss({
		title: SITE_TITLE,
		description: SITE_DESCRIPTION,
		site: context.site.href,
		items: posts.map((post) => ({
			...post.data,
			link: `/blog/${post.slug}/`,
		})),
	});
}