diff --git a/lib/db/getSiteData.js b/lib/db/getSiteData.js index f5e926c6..b898c32b 100755 --- a/lib/db/getSiteData.js +++ b/lib/db/getSiteData.js @@ -12,6 +12,7 @@ import { deepClone } from '@/lib/utils' import { idToUuid } from 'notion-utils' import { siteConfig } from '../config' import { extractLangId, extractLangPrefix, getShortId } from '../utils/pageId' +import { getOrSetDataWithCache } from '@/lib/cache/cache_manager' export { getAllTags } from '../notion/getAllTags' export { getPost } from '../notion/getNotionPost' @@ -66,13 +67,13 @@ export async function getGlobalData({ export async function getSiteDataByPageId({ pageId, from }) { // 获取NOTION原始数据,此接支持mem缓存。 const pageRecordMap = await getPage(pageId, from) - // 将Notion数据按规则转成站点数据 - const data = await converNotionToSiteDate( + return await getOrSetDataWithCache( + `site_data_${pageId}`, + converNotionToSiteDate, pageId, from, deepClone(pageRecordMap) ) - return data } /** @@ -264,11 +265,12 @@ async function converNotionToSiteDate(pageId, from, pageRecordMap) { categoryOptions: getCategoryOptions(schema) }) // 所有标签 - const tagOptions = getAllTags({ - allPages, - tagOptions: getTagOptions(schema), - NOTION_CONFIG - }) + const tagOptions = + getAllTags({ + allPages, + tagOptions: getTagOptions(schema), + NOTION_CONFIG + }) || null // 旧的菜单 const customNav = getCustomNav({ allPages: collectionData.filter(