mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 19:41:02 +08:00
fix: exclude draft posts in specific tag page
This commit is contained in:
@@ -16,25 +16,21 @@ export interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const posts: CollectionEntry<"blog">[] = await getCollection("blog");
|
const posts = await getCollection("blog");
|
||||||
|
|
||||||
const tags = getUniqueTags(posts);
|
const tags = getUniqueTags(posts);
|
||||||
|
|
||||||
return tags.map(tag => {
|
return tags.map(tag => {
|
||||||
return {
|
return {
|
||||||
params: {
|
params: { tag },
|
||||||
tag,
|
props: { tag },
|
||||||
},
|
|
||||||
props: {
|
|
||||||
tag,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const { tag } = Astro.props;
|
const { tag } = Astro.props;
|
||||||
|
|
||||||
const posts: CollectionEntry<"blog">[] = await getCollection("blog");
|
const posts = await getCollection("blog", ({ data }) => !data.draft);
|
||||||
|
|
||||||
const tagPosts = getPostsByTag(posts, tag);
|
const tagPosts = getPostsByTag(posts, tag);
|
||||||
---
|
---
|
||||||
|
|||||||
Reference in New Issue
Block a user