diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js index 7211c31e..e06553eb 100755 --- a/lib/notion/getNotionData.js +++ b/lib/notion/getNotionData.js @@ -273,10 +273,15 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) { const viewIds = rawMetadata?.view_ids const collectionData = [] + const pageIds = getAllPageIds(collectionQuery, collectionId, collectionView, viewIds) if (pageIds?.length === 0) { console.error('获取到的文章列表为空,请检查notion模板', collectionQuery, collection, collectionView, viewIds, pageRecordMap) + } else { + console.log('有效Page数量', pageIds?.length) } + + // 获取每篇文章基础数据 for (let i = 0; i < pageIds.length; i++) { const id = pageIds[i] const value = block[id]?.value @@ -291,7 +296,8 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) { } continue } - const properties = (await getPageProperties(id, block[id].value, schema, null, getTagOptions(schema))) || null + + const properties = (await getPageProperties(id, value, schema, null, getTagOptions(schema))) || null if (properties) { collectionData.push(properties) } diff --git a/lib/notion/getPageProperties.js b/lib/notion/getPageProperties.js index 92a94342..5caf9368 100644 --- a/lib/notion/getPageProperties.js +++ b/lib/notion/getPageProperties.js @@ -90,9 +90,10 @@ export default async function getPageProperties(id, value, schema, authToken, ta properties.lastEditedDate = new Date(value?.last_edited_time) properties.lastEditedDay = formatDate(new Date(value?.last_edited_time), BLOG.LANG) properties.fullWidth = value.format?.page_full_width ?? false - properties.pageIcon = mapImgUrl(value.value?.format?.page_icon, value.value) ?? '' - properties.pageCover = mapImgUrl(value.value?.format?.page_cover, value.value) ?? '' - properties.pageCoverThumbnail = mapImgUrl(value.value?.format?.page_cover, value.value, 'block', 'pageCoverThumbnail') ?? '' + properties.pageIcon = mapImgUrl(value?.format?.page_icon, value) ?? '' + properties.pageCover = mapImgUrl(value?.format?.page_cover, value) ?? '' + properties.pageCoverThumbnail = mapImgUrl(value?.format?.page_cover, value, 'block', 'pageCoverThumbnail') ?? '' + properties.content = value.content ?? [] properties.tagItems = properties?.tags?.map(tag => { return { name: tag, color: tagOptions?.find(t => t.value === tag)?.color || 'gray' } diff --git a/lib/notion/getPostBlocks.js b/lib/notion/getPostBlocks.js index 7b8bf01e..a78ade6b 100644 --- a/lib/notion/getPostBlocks.js +++ b/lib/notion/getPostBlocks.js @@ -61,6 +61,7 @@ export async function getPageWithRetry(id, from, retryAttempts = 3) { const authToken = BLOG.NOTION_ACCESS_TOKEN || null const api = new NotionAPI({ authToken, userTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone }) const pageData = await api.getPage(id) + // console.log('stringfy', JSON.stringify(pageData)) console.info('[响应成功]:', `from:${from}`) return pageData } catch (e) {