---
import { getCollection } from 'astro:content';
import DocLayout from '@layouts/DocLayout.astro';
import { render } from 'astro:content';
import { buildBreadcrumbs } from '@utils/content';

export async function getStaticPaths() {
  const pages = await getCollection('resources');
  return pages.map((page) => {
    const [lang, ...slugParts] = page.id.split('/');

    return {
      params: {
        lang,
        slug: slugParts.join('/'),
      },
      props: { page },
    };
  });
}

const { page } = Astro.props;
const { lang, slug } = Astro.params;
const { Content } = await render(page);
const breadcrumbs = await buildBreadcrumbs(lang, slug, 'resources');
const { title, description } = page.data;
---

<DocLayout title={title} description={description} breadcrumbs={breadcrumbs}>
  <Content />
</DocLayout>
