---
import { resolveAllPaths } from '../lib/utils/paths';
import type { ResolvedEntry } from '@lib/types/content';
import ArticleLayout from '@layouts/ArticleLayout.astro';
import PageLayout from '@layouts/PageLayout.astro';
import ElementLayout from '@layouts/crucible/ElementLayout.astro';

export async function getStaticPaths() {
  const entries = await resolveAllPaths();
  return entries.map((entry) => ({
    params: { path: entry.path },
    props: entry,
  }));
}

const layoutMap: Record<string, any> = {
  article: ArticleLayout,
  page: PageLayout,
  element: ElementLayout,
} as const;

const { type, entry } = Astro.props as ResolvedEntry;
const Layout = layoutMap[type];
---

<Layout entry={entry} />
