Add basic pages for blog entries

This commit is contained in:
Alexander Navarro 2023-11-11 18:48:50 -03:00
parent a9d4e94580
commit 8ca3b129dc
6 changed files with 97 additions and 2 deletions

View file

@ -0,0 +1,26 @@
---
import type { InferGetStaticPropsType, GetStaticPaths } from 'astro';
import { getCollection } from 'astro:content';
import Layout from '@layouts/Layout.astro';
import Toc from '@components/Toc/Toc';
export const getStaticPaths = (async () => {
const entries = await getCollection('blog');
return entries.map((entry) => ({
params: { slug: entry.slug },
props: entry,
}));
}) satisfies GetStaticPaths;
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
const entry = Astro.props;
const { Content, headings } = await entry.render();
---
<Layout title={entry.data.title}>
<Toc headings={headings} />
<Content />
</Layout>