From d708c7c6381b6b85eb29f63a8041fa6a080347c1 Mon Sep 17 00:00:00 2001 From: tangly Date: Tue, 18 Oct 2022 16:47:09 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E5=8D=95=E9=A1=B5=E8=AE=BF?= =?UTF-8?q?=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/[...slug].js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/[...slug].js b/pages/[...slug].js index 0cef2223..39246577 100644 --- a/pages/[...slug].js +++ b/pages/[...slug].js @@ -99,8 +99,7 @@ export async function getStaticProps({ params: { slug } }) { const fullSlug = slug.join('/') const from = `slug-props-${fullSlug}` const props = await getGlobalNotionData({ from, pageType: ['Post'] }) - const allPosts = props.allPages.filter(page => page.type === 'Post') - props.post = allPosts.find((p) => { + props.post = props.allPages.find((p) => { return p.slug === fullSlug || p.id === idToUuid(fullSlug) }) if (!props.post) { @@ -109,6 +108,7 @@ export async function getStaticProps({ params: { slug } }) { } props.post.blockMap = await getPostBlocks(props.post.id, 'slug') + const allPosts = props.allPages.filter(page => page.type === 'Post') const index = allPosts.indexOf(props.post) props.prev = allPosts.slice(index - 1, index)[0] ?? allPosts.slice(-1)[0] props.next = allPosts.slice(index + 1, index + 2)[0] ?? allPosts[0]