optimize notionconfig

This commit is contained in:
ShH Y
2023-12-09 14:53:08 +08:00
committed by GitHub
parent 5470107b3a
commit e72a332cb7

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) {
@@ -33,10 +33,13 @@ export async function getConfigMapFromConfigPage(allPages) {
}
const configPageId = configPage.id
// console.log('[Notion配置]请求配置数据 ', configPage.id)
const pageRecordMap = await getPostBlocks(configPageId, 'config-table')
// console.log('配置中心Page', configPageId, pageRecordMap)
const content = pageRecordMap.block[configPageId].value.content
for (const table of ['config-table', 'Config-Table', 'CONFIG-TABLE']) {
// console.log('[Notion配置]请求配置数据 ', configPage.id)
var pageRecordMap = await getPostBlocks(configPageId, table)
// console.log('配置中心Page', configPageId, pageRecordMap)
var content = pageRecordMap.block[configPageId].value.content
if (content) break
}
if (!content) {
console.warn('[Notion配置] 未找到配置表格', pageRecordMap.block[configPageId], pageRecordMap.block[configPageId].value)
@@ -119,9 +122,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']
}
// 只导入生效的配置