First Article&Routing

This commit is contained in:
2026-02-19 15:00:22 +01:00
parent 857467409d
commit f6eb9dd7e1
8 changed files with 90 additions and 17 deletions

28
src/pages/[...path].astro Normal file
View File

@@ -0,0 +1,28 @@
---
import { resolveAllPaths, type ResolvedEntry } from '../lib/paths';
import type { CollectionEntry } from 'astro:content';
import ArticleLayout from '../layouts/ArticleLayout.astro';
import PageLayout from '../layouts/PageLayout.astro';
export async function getStaticPaths() {
const entries = await resolveAllPaths();
return entries.map((entry) => ({
params: { path: entry.path },
props: entry,
}));
}
const { type, entry } = Astro.props as ResolvedEntry;
const props = Astro.props as ResolvedEntry;
---
{
type === 'article' && (
<ArticleLayout entry={props.entry as CollectionEntry<'articles'>} />
)
}
{
type === 'page' && (
<PageLayout entry={props.entry as CollectionEntry<'pages'>} />
)
}