mirror of
https://github.com/kremalicious/blog.git
synced 2024-06-28 16:48:00 +02:00
Matthias Kretschmann
3b25ae2282
* location component * fetching with @nanostores/query * layouts reorg * typescript plugins cleanup * location component unit test cases * fetch only when visible
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'
|
|
|
|
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 }
|
|
}
|
|
})
|
|
}
|
|
|
|
type Props = InferGetStaticPropsType<typeof getStaticPaths>
|
|
|
|
const { entry } = Astro.props
|
|
const { Content, remarkPluginFrontmatter } = await entry.render()
|
|
---
|
|
|
|
<LayoutPost
|
|
{...entry}
|
|
lead={remarkPluginFrontmatter.lead}
|
|
leadRaw={remarkPluginFrontmatter.leadRaw}
|
|
tableOfContents={remarkPluginFrontmatter.tableOfContents}
|
|
>
|
|
<Content />
|
|
</LayoutPost>
|