This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import rss from '@astrojs/rss';
|
||||
import { getCollection } from 'astro:content';
|
||||
import { site } from '../site.config';
|
||||
|
||||
export async function GET(context: { site?: URL }) {
|
||||
const [stories, briefings, episodes] = await Promise.all([
|
||||
getCollection('stories', ({ data }) => !data.draft),
|
||||
getCollection('briefings', ({ data }) => !data.draft),
|
||||
getCollection('episodes', ({ data }) => !data.draft),
|
||||
]);
|
||||
|
||||
const items = [
|
||||
...stories.map((entry) => ({
|
||||
title: entry.data.title,
|
||||
description: entry.data.description,
|
||||
pubDate: entry.data.published,
|
||||
link: `/stories/${entry.id}`,
|
||||
})),
|
||||
...briefings.map((entry) => ({
|
||||
title: entry.data.title,
|
||||
description: entry.data.description,
|
||||
pubDate: entry.data.published,
|
||||
link: `/briefing/${entry.id}`,
|
||||
})),
|
||||
...episodes.map((entry) => ({
|
||||
title: entry.data.title,
|
||||
description: entry.data.description,
|
||||
pubDate: entry.data.published,
|
||||
link: `/podcast/${entry.id}`,
|
||||
})),
|
||||
].sort((a, b) => b.pubDate.valueOf() - a.pubDate.valueOf());
|
||||
|
||||
return rss({
|
||||
title: `${site.title} ${site.qualifier}`,
|
||||
description: site.description,
|
||||
site: context.site ?? new URL('https://example.com'),
|
||||
items,
|
||||
customData: '<language>en-gb</language>',
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user