feat: create separated rss feeds
All checks were successful
Docker / build-and-push-image (push) Successful in 2m11s

This commit is contained in:
Troy 2025-05-06 22:50:48 +01:00
parent 4f9ebdcc66
commit 782bfc7c90
Signed by: troy
GPG key ID: DFC06C02ED3B4711
10 changed files with 86 additions and 6 deletions

29
src/pages/feed.xml.ts Normal file
View file

@ -0,0 +1,29 @@
import rss from "@astrojs/rss";
import { SITE } from "@consts";
import { getCollection } from "astro:content";
export async function GET(context: { site: string }) {
const posts = (await getCollection("posts")).filter(
(post) => !post.data.draft,
);
const projects = (await getCollection("projects")).filter(
(project) => !project.data.draft,
);
const items = [...posts, ...projects].sort(
(a, b) => new Date(b.data.date).valueOf() - new Date(a.data.date).valueOf(),
);
return rss({
title: SITE.TITLE,
description: SITE.DESCRIPTION,
site: context.site,
items: items.map((item) => ({
title: item.data.title,
description: item.data.description,
pubDate: item.data.date,
link: `/${item.collection}/${item.slug}/`,
})),
});
}