gallery.badmanners.xyz/src/pages/games/[...id].astro
2024-12-05 21:43:04 -03:00

29 lines
777 B
Text

---
import type { GetStaticPaths } from "astro";
import { type CollectionEntry, getCollection, render } from "astro:content";
import GameLayout from "@layouts/GameLayout.astro";
import { PUBLISH_DRAFTS } from "astro:env/server";
type Props = CollectionEntry<"games">;
type Params = {
id: CollectionEntry<"games">["id"];
};
export const getStaticPaths: GetStaticPaths = async () => {
const games = await getCollection("games");
return games
.filter((game) => import.meta.env.DEV || PUBLISH_DRAFTS || !game.data.isDraft)
.map((game) => ({
params: { id: game.id } satisfies Params,
props: game satisfies Props,
}));
};
const game = Astro.props;
const { Content } = await render(game);
---
<GameLayout {...game.data}>
<Content />
</GameLayout>