Add basic pages for blog entries
This commit is contained in:
parent
a9d4e94580
commit
8ca3b129dc
6 changed files with 97 additions and 2 deletions
26
src/pages/blog/[...slug].astro
Normal file
26
src/pages/blog/[...slug].astro
Normal 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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue