mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-blog.git
synced 2026-07-03 23:51:26 +00:00
40 lines
890 B
Text
40 lines
890 B
Text
---
|
|
import { getCollection, render } from "astro:content";
|
|
import MarkdownPostLayout from "@/layouts/MarkdownPostLayout.astro";
|
|
|
|
export async function getStaticPaths() {
|
|
const posts = await getCollection("blog");
|
|
|
|
return posts.map((post) => {
|
|
const [lang, ...slugParts] = post.id.split("/");
|
|
|
|
return {
|
|
params: {
|
|
lang,
|
|
slug: slugParts.join("/"),
|
|
},
|
|
props: {
|
|
post,
|
|
lang,
|
|
},
|
|
};
|
|
});
|
|
}
|
|
|
|
const { post, lang } = Astro.props;
|
|
const { Content, headings } = await render(post);
|
|
|
|
const [postLang, ...slugParts] = post.id.split("/");
|
|
const slug = slugParts.join("/");
|
|
---
|
|
|
|
<MarkdownPostLayout
|
|
post={post}
|
|
frontmatter={post.data}
|
|
lang={lang}
|
|
slug={slug}
|
|
postId={post.id}
|
|
headings={headings}
|
|
>
|
|
<Content />
|
|
</MarkdownPostLayout>
|