fix: 修复部分文章无法加载的问题,原因是Notion API加载时block上限1000

修复思路是在加载所有文章时,会首先一次性加载数据库中所有block,此时因为上限1000会发生溢出。之后会读取所有page的IDs,然后逐个获取page对应的block。此时如果发现ID查找不到(说明发生了溢出),则再调用API去逐一获取这些溢出了的page。可能这不是最优解。
修改的代码包括:
1. getDataBaseInfoByNotionAPI中添加上述判断逻辑。
2. 修改getPageProperties函数签名,直接传入block对应的value,而不是block数组。
This commit is contained in:
Olimi
2023-12-21 21:11:37 +08:00
committed by tangly1024.com
parent 50eb1a28fa
commit f73dddd72a
6 changed files with 64 additions and 18 deletions

View File

@@ -28,7 +28,7 @@ export async function getAllPosts({ notionPageData, from, pageType }) {
if (!value) {
continue
}
const properties = (await getPageProperties(id, block, schema, null, tagOptions)) || null
const properties = (await getPageProperties(id, block[id].value, schema, null, tagOptions)) || null
data.push(properties)
}