mirror of
https://github.com/michaelrausch/michaelrausch-24.git
synced 2025-01-31 05:29:56 +00:00
31 lines
803 B
TypeScript
31 lines
803 B
TypeScript
|
import rss from "@astrojs/rss";
|
||
|
import { getCollection } from "astro:content";
|
||
|
import { HOME } from "@consts";
|
||
|
|
||
|
type Context = {
|
||
|
site: string
|
||
|
}
|
||
|
|
||
|
export async function GET(context: Context) {
|
||
|
const blog = (await getCollection("blog"))
|
||
|
.filter(post => !post.data.draft);
|
||
|
|
||
|
const projects = (await getCollection("projects"))
|
||
|
.filter(project => !project.data.draft);
|
||
|
|
||
|
const items = [...blog, ...projects]
|
||
|
.sort((a, b) => new Date(b.data.date).valueOf() - new Date(a.data.date).valueOf());
|
||
|
|
||
|
return rss({
|
||
|
title: HOME.TITLE,
|
||
|
description: HOME.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}/`,
|
||
|
})),
|
||
|
});
|
||
|
}
|