Fix up first version and add Prettier and Docker

This commit is contained in:
Bad Manners 2024-03-20 11:34:09 -03:00
parent 09a1919d36
commit 324050ee38
87 changed files with 2210 additions and 822 deletions

View file

@ -1,34 +1,42 @@
import rss, { type RSSFeedItem } from '@astrojs/rss'
import type { APIRoute } from 'astro';
import { getCollection } from 'astro:content';
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
}
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)
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',
title: "Gallery | Bad Manners",
description: "Stories, games, and more 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'],
description:
`Word count: ${story.data.wordCount}. ${story.data.contentWarning} ${story.data.descriptionPlaintext || story.data.description}`
.replaceAll(/\n+| +/g, " ")
.trim(),
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'],
description: `${game.data.contentWarning} ${game.data.descriptionPlaintext || game.data.description}`
.replaceAll(/\n+| +/g, " ")
.trim(),
categories: ["game"],
})),
].flat().sort((a, b) => getUnixTime(b.pubDate) - getUnixTime(a.pubDate)).slice(0, 10),
})
}
]
.flat()
.sort((a, b) => getUnixTime(b.pubDate) - getUnixTime(a.pubDate))
.slice(0, 10),
});
};