aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/rss.xml.js
blob: 83f4946357857cf56c31f96357c9a806e23ff2bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';

export async function GET(context) {
	const blogPosts = await getCollection('blog');
	const microPosts = await getCollection('micro');
	const posts = [...blogPosts, ...microPosts];
	posts.sort(
		(a, b) =>
			new Date(b.data.pubDate).getTime() -
			new Date(a.data.pubDate).getTime()
	);
	return rss({
		title: SITE_TITLE,
		description: SITE_DESCRIPTION,
		site: context.site,
		items: posts.map((post) => ({
			...post.data,
			link: `/${post.collection}/${post.slug}/`,
		})),
	});
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage