mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
29eff36794
* feat: add prev/next links at the bottom of blog post * fix: update and rerun scripts in post details page after swap Resolves #358
28 lines
653 B
Plaintext
28 lines
653 B
Plaintext
---
|
|
import { type CollectionEntry, getCollection } from "astro:content";
|
|
import PostDetails from "@layouts/PostDetails.astro";
|
|
import getSortedPosts from "@utils/getSortedPosts";
|
|
|
|
export interface Props {
|
|
post: CollectionEntry<"blog">;
|
|
}
|
|
|
|
export async function getStaticPaths() {
|
|
const posts = await getCollection("blog", ({ data }) => !data.draft);
|
|
|
|
const postResult = posts.map(post => ({
|
|
params: { slug: post.slug },
|
|
props: { post },
|
|
}));
|
|
|
|
return postResult;
|
|
}
|
|
|
|
const { post } = Astro.props;
|
|
|
|
const posts = await getCollection("blog");
|
|
const sortedPosts = getSortedPosts(posts);
|
|
---
|
|
|
|
<PostDetails post={post} posts={sortedPosts} />
|