summaryrefslogtreecommitdiff
path: root/src/pages/micro/rss.xml.ts
blob: 0827ccb5beea4a4bb3ee1e1a0205fb6aaff781bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { getCollection } from "astro:content";
import rss from "@astrojs/rss";
import { siteConfig } from "@/site.config";

export const GET = async () => {
	// Get both local notes and Pleroma posts
	const [allNotes, allMicro] = await Promise.all([
		getCollection("note"),
		getCollection("micro").catch(() => []), // Fallback to empty array if micro collection fails
	]);

	// Combine and sort all micro posts
	const allMicroPosts = [...allNotes, ...allMicro].sort(
		(a, b) => b.data.publishDate.getTime() - a.data.publishDate.getTime(),
	);

	return rss({
		title: siteConfig.title,
		description: siteConfig.description,
		site: import.meta.env.SITE,
		items: allMicroPosts.map((post) => ({
			title: post.data.title,
			pubDate: post.data.publishDate,
			link: `micro/${post.id}/`,
			description: post.data.description,
		})),
	});
};