mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-24 23:16:52 +00:00
完善获取文章列表
This commit is contained in:
@@ -21,22 +21,22 @@ export async function getAllPosts({ notionPageData, from, pageType }) {
|
||||
return []
|
||||
}
|
||||
|
||||
const pageBlock = notionPageData.block
|
||||
const schema = notionPageData.schema
|
||||
const tagOptions = notionPageData.tags
|
||||
const collectionQuery = notionPageData.collectionQuery
|
||||
|
||||
const { block, schema, tagOptions, collectionQuery, collectionId, collectionView, viewIds } = notionPageData
|
||||
const data = []
|
||||
const pageIds = getAllPageIds(collectionQuery)
|
||||
const pageIds = getAllPageIds(collectionQuery, collectionId, collectionView, viewIds)
|
||||
for (let i = 0; i < pageIds.length; i++) {
|
||||
const id = pageIds[i]
|
||||
const properties = (await getPageProperties(id, pageBlock, schema)) || null
|
||||
const properties = (await getPageProperties(id, block, schema)) || null
|
||||
const value = block[id]?.value
|
||||
if (!value) {
|
||||
continue
|
||||
}
|
||||
properties.slug = properties.slug ?? properties.id
|
||||
properties.createdTime = formatDate(new Date(pageBlock[id].value?.created_time).toString(), BLOG.LANG)
|
||||
properties.lastEditedTime = formatDate(new Date(pageBlock[id].value?.last_edited_time).toString(), BLOG.LANG)
|
||||
properties.fullWidth = pageBlock[id].value?.format?.page_full_width ?? false
|
||||
properties.page_cover = getPostCover(id, pageBlock) ?? null
|
||||
properties.content = pageBlock[id].value?.content ?? []
|
||||
properties.createdTime = formatDate(new Date(value.created_time).toString(), BLOG.LANG)
|
||||
properties.lastEditedTime = formatDate(new Date(value?.last_edited_time).toString(), BLOG.LANG)
|
||||
properties.fullWidth = value.format?.page_full_width ?? false
|
||||
properties.page_cover = getPostCover(id, block) ?? null
|
||||
properties.content = value.content ?? []
|
||||
properties.tagItems = properties?.tags?.map(tag => {
|
||||
return { name: tag, color: tagOptions.find(t => t.value === tag)?.color || 'gray' }
|
||||
}) || []
|
||||
|
||||
Reference in New Issue
Block a user