---
import EditionLayout from "../../layouts/EditionLayout.astro";
import EditionToc from "../../components/EditionToc.astro";
import LocalToc from "../../components/LocalToc.astro";
import { getCollection, render } from "astro:content";

export async function getStaticPaths() {
  const entries = await getCollection("archicrat-ia");

  return entries.map((entry) => ({
    params: { slug: String(entry.id).replace(/\.(md|mdx)$/i, "") },
    props: { entry }
  }));
}

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

<EditionLayout
  title={entry.data.title}
  editionLabel="Essai-thèse"
  editionKey="archicrat-ia"
  statusLabel="Essai-thèse"
  statusKey="essai_these"
  level={entry.data.level ?? 1}
  version={entry.data.version}
>
  <Fragment slot="aside">
    <EditionToc
      currentSlug={String(entry.id).replace(/\.(md|mdx)$/i, "")}
      collection="archicrat-ia"
      basePath="/archicrat-ia"
      label="Table des matières — ArchiCraT-IA"
    />
    <LocalToc headings={headings} />
  </Fragment>

  <h1>{entry.data.title}</h1>
  <Content />
</EditionLayout>