From 1eb63c5e46f0f4c039d37e62ea6df729c7d53601 Mon Sep 17 00:00:00 2001 From: expoli <31023767+expoli@users.noreply.github.com> Date: Thu, 19 Jan 2023 21:29:04 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20search=20=E6=96=87=E7=AB=A0=E6=95=B0?= =?UTF-8?q?=E7=9B=AE=E4=B8=8E=E6=A0=87=E7=AD=BE=E6=95=B0=E7=9B=AE=E4=B8=8D?= =?UTF-8?q?=E5=AF=B9=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/search/[keyword]/index.js | 2 +- pages/search/[keyword]/page/[page].js | 2 +- pages/search/index.js | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pages/search/[keyword]/index.js b/pages/search/[keyword]/index.js index 69296070..f5616d5c 100644 --- a/pages/search/[keyword]/index.js +++ b/pages/search/[keyword]/index.js @@ -43,7 +43,7 @@ export async function getStaticProps({ params: { keyword } }) { if (BLOG.POST_LIST_STYLE === 'scroll') { // 滚动列表 给前端返回所有数据 } else if (BLOG.POST_LIST_STYLE === 'page') { - props.posts = props.posts?.slice(0, BLOG.POSTS_PER_PAGE - 1) + props.posts = props.posts?.slice(0, BLOG.POSTS_PER_PAGE) } props.keyword = keyword return { diff --git a/pages/search/[keyword]/page/[page].js b/pages/search/[keyword]/page/[page].js index 4ec2f819..1255f3c3 100644 --- a/pages/search/[keyword]/page/[page].js +++ b/pages/search/[keyword]/page/[page].js @@ -40,7 +40,7 @@ export async function getStaticProps({ params: { keyword, page } }) { props.posts = await filterByMemCache(allPosts, keyword) props.postCount = props.posts.length // 处理分页 - props.posts = props.posts.slice(BLOG.POSTS_PER_PAGE * (page - 1), BLOG.POSTS_PER_PAGE * page - 1) + props.posts = props.posts.slice(BLOG.POSTS_PER_PAGE * (page - 1), BLOG.POSTS_PER_PAGE * page) props.keyword = keyword props.page = page delete props.allPages diff --git a/pages/search/index.js b/pages/search/index.js index d90a3cf7..e8f51d32 100644 --- a/pages/search/index.js +++ b/pages/search/index.js @@ -55,8 +55,7 @@ export async function getStaticProps() { pageType: ['Post'] }) const { allPages } = props - const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published') - props.posts = allPosts + props.posts = allPages.filter(page => page.type === 'Post' && page.status === 'Published') return { props, revalidate: parseInt(BLOG.NEXT_REVALIDATE_SECOND)