Initial commit
This commit is contained in:
commit
09a1919d36
152 changed files with 22845 additions and 0 deletions
34
src/pages/feed.xml.ts
Normal file
34
src/pages/feed.xml.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import rss, { type RSSFeedItem } from '@astrojs/rss'
|
||||
import type { APIRoute } from 'astro';
|
||||
import { getCollection } from 'astro:content';
|
||||
import { getUnixTime, addHours } from "date-fns";
|
||||
|
||||
type FeedItem = RSSFeedItem & {
|
||||
pubDate: Date
|
||||
}
|
||||
|
||||
export const GET: APIRoute = async ({ site }) => {
|
||||
const stories = (await getCollection('stories')).filter(story => !story.data.isDraft)
|
||||
const games = (await getCollection('games')).filter(game => !game.data.isDraft)
|
||||
return rss({
|
||||
title: 'Gallery | Bad Manners',
|
||||
description: 'Stories, games, and artwork by Bad Manners',
|
||||
site: site as URL,
|
||||
items: [
|
||||
stories.map<FeedItem>((story) => ({
|
||||
title: `New story! "${story.data.title}"`,
|
||||
pubDate: addHours(story.data.pubDate, 12),
|
||||
link: `/stories/${story.slug}`,
|
||||
description: `Word count: ${story.data.wordCount}. ${story.data.contentWarning} ${story.data.descriptionPlaintext || story.data.description}`,
|
||||
categories: ['story'],
|
||||
})),
|
||||
games.map<FeedItem>((game) => ({
|
||||
title: `New game! "${game.data.title}"`,
|
||||
pubDate: addHours(game.data.pubDate, 12),
|
||||
link: `/games/${game.slug}`,
|
||||
description: `${game.data.contentWarning} ${game.data.descriptionPlaintext || game.data.description}`,
|
||||
categories: ['game'],
|
||||
})),
|
||||
].flat().sort((a, b) => getUnixTime(b.pubDate) - getUnixTime(a.pubDate)).slice(0, 10),
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue