diff --git a/lib/notion/getAllPageIds.js b/lib/notion/getAllPageIds.js index 44b80d38..e8f6dd8f 100644 --- a/lib/notion/getAllPageIds.js +++ b/lib/notion/getAllPageIds.js @@ -11,10 +11,10 @@ export default function getAllPageIds (collectionQuery, collectionId, collection view?.collection_group_results?.blockIds?.forEach(id => pageSet.add(id)) // table视图 }) pageIds = [...pageSet] - console.log('PageIds: 从collectionQuery获取', collectionQuery, pageIds.length) + // console.log('PageIds: 从collectionQuery获取', collectionQuery, pageIds.length) } else if (viewIds && viewIds.length > 0) { const ids = collectionView[viewIds[0]].value.page_sort - console.log('PageIds: 从viewId获取', viewIds) + // console.log('PageIds: 从viewId获取', viewIds) for (const id of ids) { pageIds.push(id) } diff --git a/pages/archive/index.js b/pages/archive/index.js index fda51dc5..098da940 100644 --- a/pages/archive/index.js +++ b/pages/archive/index.js @@ -20,7 +20,10 @@ const ArchiveIndex = props => { export async function getStaticProps() { const props = await getGlobalNotionData({ from: 'archive-index' }) - props.posts = props.allPosts + const { allPages } = props + const allPosts = allPages.filter(page => page.type === 'Post') + // 处理分页 + props.posts = allPosts return { props, revalidate: 1 diff --git a/pages/category/[category].js b/pages/category/[category].js index ac44bb05..6c07adcf 100644 --- a/pages/category/[category].js +++ b/pages/category/[category].js @@ -26,7 +26,9 @@ export default function Category(props) { export async function getStaticProps({ params: { category } }) { const from = 'category-props' let props = await getGlobalNotionData({ from }) - const posts = props.allPosts.filter( + const { allPages } = props + const allPosts = allPages.filter(page => page.type === 'Post') + const posts = allPosts.filter( post => post && post.category && post.category.includes(category) ) props = { ...props, posts, category } diff --git a/pages/page/[page].js b/pages/page/[page].js index f86b0902..a7b49e82 100644 --- a/pages/page/[page].js +++ b/pages/page/[page].js @@ -38,8 +38,10 @@ export async function getStaticProps({ params: { page } }) { const from = `page-${page}` const props = await getGlobalNotionData({ from }) props.page = page + const { allPages } = props + const allPosts = allPages.filter(page => page.type === 'Post') // 处理分页 - props.posts = props.allPosts.slice( + props.posts = allPosts.slice( BLOG.POSTS_PER_PAGE * (page - 1), BLOG.POSTS_PER_PAGE * page ) diff --git a/pages/search/[keyword].js b/pages/search/[keyword].js index 03fb8109..3de56ed1 100644 --- a/pages/search/[keyword].js +++ b/pages/search/[keyword].js @@ -35,7 +35,9 @@ export async function getStaticProps({ params: { keyword } }) { from: 'search-props', pageType: ['Post'] }) - props.posts = await filterByMemCache(props.allPosts, keyword) + const { allPages } = props + const allPosts = allPages.filter(page => page.type === 'Post') + props.posts = await filterByMemCache(allPosts, keyword) props.keyword = keyword return { props, diff --git a/pages/search/index.js b/pages/search/index.js index 30e97c95..7cee6392 100644 --- a/pages/search/index.js +++ b/pages/search/index.js @@ -52,7 +52,9 @@ export async function getStaticProps() { from: 'search-props', pageType: ['Post'] }) - props.posts = props.allPosts + const { allPages } = props + const allPosts = allPages.filter(page => page.type === 'Post') + props.posts = allPosts return { props, revalidate: 1 diff --git a/pages/tag/[tag].js b/pages/tag/[tag].js index 121dc973..37606158 100644 --- a/pages/tag/[tag].js +++ b/pages/tag/[tag].js @@ -28,7 +28,8 @@ export async function getStaticProps({ params: { tag } }) { includePage: false, tagsCount: 0 }) - const { allPosts } = props + const { allPages } = props + const allPosts = allPages.filter(page => page.type === 'Post') props.posts = allPosts.filter( post => post && post.tags && post.tags.includes(tag) )