From dc95a4cb5baf329ba00f8869b41ba56aa38eba28 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 2 Mar 2022 17:35:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=9B=9E=E4=BB=8E=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/search/[keyword].js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pages/search/[keyword].js b/pages/search/[keyword].js index 870071b4..1ab5584e 100644 --- a/pages/search/[keyword].js +++ b/pages/search/[keyword].js @@ -2,7 +2,7 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import { LayoutSearch } from '@/themes' import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' -import { getPostBlocks } from '@/lib/notion/getPostBlocks' +import { getDataFromCache } from '@/lib/cache/cache_manager' /** * 将对象的指定字段拼接到字符串 @@ -59,14 +59,15 @@ export async function getServerSideProps ({ params: { keyword } }) { const filterPosts = [] for (const post of allPosts) { - // const cacheKey = 'page_block_' + post.id - const page = await getPostBlocks(post.id, 'search') + const cacheKey = 'page_block_' + post.id + // const page = await getPostBlocks(post.id, 'search') + const page = await getDataFromCache(cacheKey) const tagContent = post.tags ? post.tags.join(' ') : '' const categoryContent = post.category ? post.category.join(' ') : '' const articleInfo = post.title + post.summary + tagContent + categoryContent let hit = articleInfo.indexOf(keyword) > -1 let indexContent = [post.summary] - if (page !== null) { + if (page && page.block) { const contentIds = Object.keys(page.block) contentIds.forEach(id => { const properties = page?.block[id]?.value?.properties