first commit

This commit is contained in:
Troy 2024-12-23 21:18:55 +00:00
commit ff7c974867
Signed by: troy
GPG key ID: DFC06C02ED3B4711
227 changed files with 12908 additions and 0 deletions

29
src/pages/rss.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}/`,
})),
});
}