mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
fix: disable access to draft posts via url
This commit is contained in:
@@ -30,7 +30,9 @@ type PagePaths = {
|
||||
export async function getStaticPaths() {
|
||||
const posts = await Astro.glob<Frontmatter>("../../contents/**/*.md");
|
||||
|
||||
let postResult: PostResult = posts.map(post => {
|
||||
const filteredPosts = posts.filter(({ frontmatter }) => !frontmatter.draft);
|
||||
|
||||
let postResult: PostResult = filteredPosts.map(post => {
|
||||
return {
|
||||
params: {
|
||||
slug: slugify(post.frontmatter),
|
||||
@@ -41,9 +43,11 @@ export async function getStaticPaths() {
|
||||
};
|
||||
});
|
||||
|
||||
const pagePaths: PagePaths = getPageNumbers(posts.length).map(pageNum => ({
|
||||
const pagePaths: PagePaths = getPageNumbers(filteredPosts.length).map(
|
||||
pageNum => ({
|
||||
params: { slug: String(pageNum) },
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
return [...postResult, ...pagePaths];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user