mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-05 07:26:46 +00:00
多语言配置,starter主题微调、兼容
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
*
|
||||
*/
|
||||
import { getDateValue, getTextContent } from 'notion-utils'
|
||||
import { deepClone } from '../utils'
|
||||
import getAllPageIds from './getAllPageIds'
|
||||
import { getPostBlocks } from './getPostBlocks'
|
||||
|
||||
@@ -162,9 +163,12 @@ export async function getConfigMapFromConfigPage(allPages) {
|
||||
}
|
||||
|
||||
// 最后检查Notion_Config页面的INLINE_CONFIG,是否是一个js对象
|
||||
const inlineConfigs = parseConfig(configPage?.INLINE_CONFIG)
|
||||
|
||||
return Object.assign({}, notionConfig, inlineConfigs)
|
||||
const combine = Object.assign(
|
||||
{},
|
||||
deepClone(notionConfig),
|
||||
parseConfig(notionConfig?.INLINE_CONFIG)
|
||||
)
|
||||
return combine
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,19 +180,13 @@ export function parseConfig(configString) {
|
||||
if (!configString) {
|
||||
return {}
|
||||
}
|
||||
// 解析对象
|
||||
try {
|
||||
// 尝试解析为 JSON 对象
|
||||
const jsonConfig = JSON.parse(configString)
|
||||
return jsonConfig
|
||||
} catch (error) {
|
||||
// 如果解析失败,则尝试使用 eval()
|
||||
try {
|
||||
// eslint-disable-next-line no-eval
|
||||
const config = eval('(' + configString + ')')
|
||||
return config
|
||||
} catch (evalError) {
|
||||
console.error('解析 INLINE_CONFIG 配置时出错:', evalError)
|
||||
return {}
|
||||
}
|
||||
// eslint-disable-next-line no-eval
|
||||
const config = eval('(' + configString + ')')
|
||||
return config
|
||||
} catch (evalError) {
|
||||
console.error('解析 eval(INLINE_CONFIG) 配置时出错:', evalError)
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user