mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
fix page-cover-missing
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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' }
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user