mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
perf(SiteData站点数据 转换使用缓存优化): 复杂的数据转换函数使用缓存优化
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user