Merge pull request #1700 from 1208nn/main

Update lib/notion/getNotionConfig.js
This commit is contained in:
tangly1024
2023-12-27 18:54:39 +08:00
committed by GitHub

View File

@@ -24,7 +24,7 @@ export async function getConfigMapFromConfigPage(allPages) {
return null
}
const configPage = allPages?.find(post => {
return post && post?.type && post?.type === 'CONFIG'
return post && post?.type && (post?.type === 'CONFIG' || post?.type === 'config' || post?.type === 'Config')
})
if (!configPage) {
@@ -32,11 +32,15 @@ export async function getConfigMapFromConfigPage(allPages) {
return null
}
const configPageId = configPage.id
// console.log('[Notion配置]请求配置数据 ', configPage.id)
const pageRecordMap = await getPostBlocks(configPageId, 'config-table')
let pageRecordMap = await getPostBlocks(configPageId, 'config-table')
// console.log('配置中心Page', configPageId, pageRecordMap)
const content = pageRecordMap.block[configPageId].value.content
let content = pageRecordMap.block[configPageId].value.content
for (const table of ['Config-Table', 'CONFIG-TABLE']) {
if (content) break
pageRecordMap = await getPostBlocks(configPageId, table)
content = pageRecordMap.block[configPageId].value.content
}
if (!content) {
console.warn('[Notion配置] 未找到配置表格', pageRecordMap.block[configPageId], pageRecordMap.block[configPageId].value)
@@ -119,9 +123,9 @@ export async function getConfigMapFromConfigPage(allPages) {
if (properties) {
// 将表格中的字段映射成 英文
const config = {
enable: properties['启用'] === 'Yes',
key: properties['配置名'],
value: properties['配置值']
enable: (properties['启用'] || properties.Enable) === 'Yes',
key: properties['配置名'] || properties.Name,
value: properties['配置值'] || properties.Value
}
// 只导入生效的配置