From cd233f506035778c5694aabae320a297d466854b Mon Sep 17 00:00:00 2001 From: tangly Date: Thu, 20 Oct 2022 13:01:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9A=90=E8=97=8F=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/notion/getNotionData.js | 2 +- pages/[...slug].js | 2 +- pages/archive/index.js | 2 +- pages/category/[category].js | 2 +- pages/index.js | 2 +- pages/page/[page].js | 2 +- pages/search/[keyword].js | 2 +- pages/search/index.js | 2 +- pages/tag/[tag].js | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js index 21a43c37..c74552cb 100644 --- a/lib/notion/getNotionData.js +++ b/lib/notion/getNotionData.js @@ -257,7 +257,7 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) { let postCount = 0 const allPages = collectionData.filter(post => { - if (post.type === 'Post' && (post.status === 'Published' || post.status === 'Invisible')) { + if (post.type === 'Post' && post.status === 'Published') { postCount++ } diff --git a/pages/[...slug].js b/pages/[...slug].js index 015f053f..97327526 100644 --- a/pages/[...slug].js +++ b/pages/[...slug].js @@ -98,7 +98,7 @@ export async function getStaticProps({ params: { slug } }) { // slug 是个数组 const fullSlug = slug.join('/') const from = `slug-props-${fullSlug}` - const props = await getGlobalNotionData({ from, pageType: ['Post'] }) + const props = await getGlobalNotionData({ from }) props.post = props.allPages.find((p) => { return p.slug === fullSlug || p.id === idToUuid(fullSlug) }) diff --git a/pages/archive/index.js b/pages/archive/index.js index 098da940..ed40b48a 100644 --- a/pages/archive/index.js +++ b/pages/archive/index.js @@ -21,7 +21,7 @@ const ArchiveIndex = props => { export async function getStaticProps() { const props = await getGlobalNotionData({ from: 'archive-index' }) const { allPages } = props - const allPosts = allPages.filter(page => page.type === 'Post') + const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published') // 处理分页 props.posts = allPosts return { diff --git a/pages/category/[category].js b/pages/category/[category].js index 6c07adcf..6082c336 100644 --- a/pages/category/[category].js +++ b/pages/category/[category].js @@ -27,7 +27,7 @@ export async function getStaticProps({ params: { category } }) { const from = 'category-props' let props = await getGlobalNotionData({ from }) const { allPages } = props - const allPosts = allPages.filter(page => page.type === 'Post') + const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published') const posts = allPosts.filter( post => post && post.category && post.category.includes(category) ) diff --git a/pages/index.js b/pages/index.js index 3c49f983..92a70474 100644 --- a/pages/index.js +++ b/pages/index.js @@ -13,7 +13,7 @@ export async function getStaticProps() { const from = 'index' const props = await getGlobalNotionData({ from }) const { allPages, siteInfo } = props - const allPosts = allPages.filter(page => page.type === 'Post') + const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published') const meta = { title: `${siteInfo?.title} | ${siteInfo?.description}`, description: siteInfo?.description, diff --git a/pages/page/[page].js b/pages/page/[page].js index a7b49e82..a09f08d1 100644 --- a/pages/page/[page].js +++ b/pages/page/[page].js @@ -39,7 +39,7 @@ export async function getStaticProps({ params: { page } }) { const props = await getGlobalNotionData({ from }) props.page = page const { allPages } = props - const allPosts = allPages.filter(page => page.type === 'Post') + const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published') // 处理分页 props.posts = allPosts.slice( BLOG.POSTS_PER_PAGE * (page - 1), diff --git a/pages/search/[keyword].js b/pages/search/[keyword].js index dc992481..e478920d 100644 --- a/pages/search/[keyword].js +++ b/pages/search/[keyword].js @@ -36,7 +36,7 @@ export async function getStaticProps({ params: { keyword } }) { pageType: ['Post'] }) const { allPages } = props - const allPosts = allPages.filter(page => page.type === 'Post') + const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published') props.posts = await filterByMemCache(allPosts, keyword) props.keyword = keyword return { diff --git a/pages/search/index.js b/pages/search/index.js index 7cee6392..4dd96ad5 100644 --- a/pages/search/index.js +++ b/pages/search/index.js @@ -53,7 +53,7 @@ export async function getStaticProps() { pageType: ['Post'] }) const { allPages } = props - const allPosts = allPages.filter(page => page.type === 'Post') + const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published') props.posts = allPosts return { props, diff --git a/pages/tag/[tag].js b/pages/tag/[tag].js index 37606158..875a8768 100644 --- a/pages/tag/[tag].js +++ b/pages/tag/[tag].js @@ -29,7 +29,7 @@ export async function getStaticProps({ params: { tag } }) { tagsCount: 0 }) const { allPages } = props - const allPosts = allPages.filter(page => page.type === 'Post') + const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published') props.posts = allPosts.filter( post => post && post.tags && post.tags.includes(tag) )