---
import {
  InferGetStaticParamsType,
  InferGetStaticPropsType,
  GetStaticPaths,
} from 'astro';
import { getCollection } from 'astro:content';
import Layout from '@layouts/Layout.astro';
import Toc from '@components/Toc/Toc';

export const getStaticPaths = (async () => {
  const games = await getCollection('games');

  return games.map((entry) => ({
    params: { slug: entry.slug },
    props: entry,
  }));
}) satisfies GetStaticPaths;

type Props = InferGetStaticPropsType<typeof getStaticPaths>;

const entry = Astro.props;
const { Content, headings } = await entry.render();
---

<Layout title={entry.data.title}>
  <Toc headings={headings} />

  <Content />
</Layout>
