---
import SiteLayout from "../../layouts/SiteLayout.astro";
import { getCollection } from "astro:content";

// ✅ Après migration physique : collection = "archicrat-ia", slug = "chapitre-3" (sans prefix)
const entries = await getCollection("archicrat-ia");

entries.sort((a, b) => (a.data.order ?? 9999) - (b.data.order ?? 9999));

const href = (slug) => `/archicrat-ia/${slug}/`;
---

<SiteLayout title="Essai-thèse — ArchiCraT-IA">
  <h1>Essai-thèse — ArchiCraT-IA</h1>

  <ul>
    {entries.map((e) => (
      <li><a href={href(e.slug)}>{e.data.title}</a></li>
    ))}
  </ul>
</SiteLayout>