Merge branch 'main' into release/4.8.1

This commit is contained in:
tangly1024
2025-01-05 20:00:11 +08:00
20 changed files with 633 additions and 419 deletions

View File

@@ -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'
@@ -65,14 +66,15 @@ 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}`,
async (pageId, from) => {
const pageRecordMap = await getPage(pageId, from)
return convertNotionToSiteDate(pageId, from, deepClone(pageRecordMap))
},
pageId,
from,
deepClone(pageRecordMap)
from
)
return data
}
/**
@@ -139,7 +141,7 @@ const EmptyData = pageId => {
* 这里统一对数据格式化
* @returns {Promise<JSX.Element|null|*>}
*/
async function converNotionToSiteDate(pageId, from, pageRecordMap) {
async function convertNotionToSiteDate(pageId, from, pageRecordMap) {
if (!pageRecordMap) {
console.error('can`t get Notion Data ; Which id is: ', pageId)
return {}
@@ -273,11 +275,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(