mirror of
https://github.com/kremalicious/blog.git
synced 2024-06-30 21:52:05 +02:00
34 lines
803 B
Plaintext
34 lines
803 B
Plaintext
|
---
|
||
|
import LayoutPost from '@layouts/Post/index.astro'
|
||
|
import { getAllPosts } from '@lib/astro'
|
||
|
import type { InferGetStaticPropsType } from 'astro'
|
||
|
|
||
|
type Props = InferGetStaticPropsType<typeof getStaticPaths>
|
||
|
|
||
|
export async function getStaticPaths() {
|
||
|
const allPosts = await getAllPosts()
|
||
|
|
||
|
return allPosts.map((entry) => {
|
||
|
if (!entry?.slug) {
|
||
|
throw new Error('Missing `slug` field in entry', entry)
|
||
|
}
|
||
|
return {
|
||
|
params: { slug: entry.slug },
|
||
|
props: { entry }
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
const { entry } = Astro.props
|
||
|
const { Content, remarkPluginFrontmatter } = await entry.render()
|
||
|
---
|
||
|
|
||
|
<LayoutPost
|
||
|
{...entry}
|
||
|
lead={remarkPluginFrontmatter.lead}
|
||
|
leadRaw={remarkPluginFrontmatter.leadRaw}
|
||
|
tableOfContents={remarkPluginFrontmatter.tableOfContents}
|
||
|
>
|
||
|
<Content />
|
||
|
</LayoutPost>
|