mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-13 23:16:47 +00:00
保留inline_config
This commit is contained in:
@@ -157,19 +157,24 @@ export async function getConfigMapFromConfigPage(allPages) {
|
||||
// 只导入生效的配置
|
||||
if (config.enable) {
|
||||
// console.log('[Notion配置]', config.key, config.value)
|
||||
notionConfig[config.key] = parseTextToJson(config.value) || config.value || null
|
||||
notionConfig[config.key] =
|
||||
parseTextToJson(config.value) || config.value || null
|
||||
// 配置不能是undefined,至少是null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 将INLINE_CONFIG合并,@see https://docs.tangly1024.com/article/notion-next-inline-config
|
||||
const combine = Object.assign(
|
||||
{},
|
||||
deepClone(notionConfig),
|
||||
parseConfig(notionConfig?.INLINE_CONFIG)
|
||||
)
|
||||
let combine = notionConfig
|
||||
try {
|
||||
// 将INLINE_CONFIG合并,@see https://docs.tangly1024.com/article/notion-next-inline-config
|
||||
combine = Object.assign(
|
||||
{},
|
||||
deepClone(notionConfig),
|
||||
notionConfig?.INLINE_CONFIG
|
||||
)
|
||||
} catch (err) {
|
||||
console.warn('解析 INLINE_CONFIG 配置时出错,请检查JSON格式', err)
|
||||
}
|
||||
return combine
|
||||
}
|
||||
|
||||
@@ -188,7 +193,10 @@ export function parseConfig(configString) {
|
||||
const config = eval('(' + configString + ')')
|
||||
return config
|
||||
} catch (evalError) {
|
||||
console.error('解析 eval(INLINE_CONFIG) 配置时出错:', evalError)
|
||||
console.warn(
|
||||
'解析 eval(INLINE_CONFIG) 配置时出错,请检查JSON格式',
|
||||
evalError
|
||||
)
|
||||
return {}
|
||||
}
|
||||
}
|
||||
@@ -200,8 +208,8 @@ export function parseConfig(configString) {
|
||||
*/
|
||||
export function parseTextToJson(text) {
|
||||
try {
|
||||
return JSON.parse(text);
|
||||
return JSON.parse(text)
|
||||
} catch (error) {
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user