---
import { getCollection, render } from 'astro:content';
import DocsLayout from '../../layouts/DocsLayout.astro';

export async function getStaticPaths() {
  const entries = await getCollection('docs');
  return entries.map((entry) => ({
    params: { slug: entry.id },
    props: { entry, entries },
  }));
}

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

const nav = entries.map((e) => ({
  slug: e.id,
  title: e.data.title,
  section: e.data.section,
  order: e.data.order,
}));
---

<DocsLayout
  title={entry.data.title}
  description={entry.data.description}
  currentSlug={entry.id}
  nav={nav}
  headings={headings}
>
  <Content />
</DocsLayout>
