修复映射Notion数据库字段

This commit is contained in:
tangly
2022-10-17 22:07:51 +08:00
parent 07d48ae632
commit 96d1a85a93
4 changed files with 28 additions and 18 deletions

View File

@@ -251,13 +251,21 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) {
collectionData.push(properties)
}
}
// 读取映射 配置
console.log('当前Notion映射配置-(在blog.config.js中配置)', BLOG.NOTION_PROPERTY_NAME)
const { type, status } = BLOG.NOTION_PROPERTY_NAME
const allPages = collectionData.filter(post => {
return post.title && ['Page'].indexOf(post?.type?.[0]) > -1 && (post?.status?.[0] === 'Published' || post?.status?.[0] === 'Invisible')
return post && post[type] &&
['Page'].indexOf(post[type]?.[0]) > -1 &&
(post[status]?.[0] === 'Published' || post[status]?.[0] === 'Invisible')
})
const allPosts = collectionData.filter(post => {
return post.title && ['Post'].indexOf(post?.type?.[0]) > -1 && post?.status?.[0] === 'Published'
return post && post[status] &&
['Post'].indexOf(post[type]?.[0]) > -1 &&
post[status]?.[0] === 'Published'
})
console.error('全部单页', allPages.length, '全部博客', allPosts.length)
// Sort by date
if (BLOG.POSTS_SORT_BY === 'date') {