Fix dates and finish Tiny Accident

This commit is contained in:
Bad Manners 2024-03-25 11:36:54 -03:00
parent 808f565e59
commit b92f53a9c2
6 changed files with 86 additions and 71 deletions

View file

@ -1,7 +1,7 @@
import rss, { type RSSFeedItem } from "@astrojs/rss";
import type { APIRoute } from "astro";
import { getCollection } from "astro:content";
import { getUnixTime, addHours } from "date-fns";
import { getUnixTime, addMinutes } from "date-fns";
type FeedItem = RSSFeedItem & {
pubDate: Date;
@ -17,7 +17,7 @@ export const GET: APIRoute = async ({ site }) => {
items: [
stories.map<FeedItem>((story) => ({
title: `New story! "${story.data.title}"`,
pubDate: addHours(story.data.pubDate, 12),
pubDate: addMinutes(story.data.pubDate, 12 * 60 - story.data.pubDate.getTimezoneOffset()),
link: `/stories/${story.slug}`,
description:
`Word count: ${story.data.wordCount}. ${story.data.contentWarning} ${story.data.descriptionPlaintext || story.data.description}`
@ -27,7 +27,7 @@ export const GET: APIRoute = async ({ site }) => {
})),
games.map<FeedItem>((game) => ({
title: `New game! "${game.data.title}"`,
pubDate: addHours(game.data.pubDate, 12),
pubDate: addMinutes(game.data.pubDate, 12 * 60 - game.data.pubDate.getTimezoneOffset()),
link: `/games/${game.slug}`,
description: `${game.data.contentWarning} ${game.data.descriptionPlaintext || game.data.description}`
.replaceAll(/[\n ]+/g, " ")