mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-03 07:26:45 +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 viewIds = rawMetadata?.view_ids
|
||||||
const collectionData = []
|
const collectionData = []
|
||||||
|
|
||||||
const pageIds = getAllPageIds(collectionQuery, collectionId, collectionView, viewIds)
|
const pageIds = getAllPageIds(collectionQuery, collectionId, collectionView, viewIds)
|
||||||
if (pageIds?.length === 0) {
|
if (pageIds?.length === 0) {
|
||||||
console.error('获取到的文章列表为空,请检查notion模板', collectionQuery, collection, collectionView, viewIds, pageRecordMap)
|
console.error('获取到的文章列表为空,请检查notion模板', collectionQuery, collection, collectionView, viewIds, pageRecordMap)
|
||||||
|
} else {
|
||||||
|
console.log('有效Page数量', pageIds?.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取每篇文章基础数据
|
||||||
for (let i = 0; i < pageIds.length; i++) {
|
for (let i = 0; i < pageIds.length; i++) {
|
||||||
const id = pageIds[i]
|
const id = pageIds[i]
|
||||||
const value = block[id]?.value
|
const value = block[id]?.value
|
||||||
@@ -291,7 +296,8 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
|
|||||||
}
|
}
|
||||||
continue
|
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) {
|
if (properties) {
|
||||||
collectionData.push(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.lastEditedDate = new Date(value?.last_edited_time)
|
||||||
properties.lastEditedDay = formatDate(new Date(value?.last_edited_time), BLOG.LANG)
|
properties.lastEditedDay = formatDate(new Date(value?.last_edited_time), BLOG.LANG)
|
||||||
properties.fullWidth = value.format?.page_full_width ?? false
|
properties.fullWidth = value.format?.page_full_width ?? false
|
||||||
properties.pageIcon = mapImgUrl(value.value?.format?.page_icon, value.value) ?? ''
|
properties.pageIcon = mapImgUrl(value?.format?.page_icon, value) ?? ''
|
||||||
properties.pageCover = mapImgUrl(value.value?.format?.page_cover, value.value) ?? ''
|
properties.pageCover = mapImgUrl(value?.format?.page_cover, value) ?? ''
|
||||||
properties.pageCoverThumbnail = mapImgUrl(value.value?.format?.page_cover, value.value, 'block', 'pageCoverThumbnail') ?? ''
|
properties.pageCoverThumbnail = mapImgUrl(value?.format?.page_cover, value, 'block', 'pageCoverThumbnail') ?? ''
|
||||||
|
|
||||||
properties.content = value.content ?? []
|
properties.content = value.content ?? []
|
||||||
properties.tagItems = properties?.tags?.map(tag => {
|
properties.tagItems = properties?.tags?.map(tag => {
|
||||||
return { name: tag, color: tagOptions?.find(t => t.value === tag)?.color || 'gray' }
|
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 authToken = BLOG.NOTION_ACCESS_TOKEN || null
|
||||||
const api = new NotionAPI({ authToken, userTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone })
|
const api = new NotionAPI({ authToken, userTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone })
|
||||||
const pageData = await api.getPage(id)
|
const pageData = await api.getPage(id)
|
||||||
|
// console.log('stringfy', JSON.stringify(pageData))
|
||||||
console.info('[响应成功]:', `from:${from}`)
|
console.info('[响应成功]:', `from:${from}`)
|
||||||
return pageData
|
return pageData
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user