mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-17 23:16:50 +00:00
Merge branch 'main' into release/4.8.1
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'
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user