Next主题可隐藏头图,并显示icon

This commit is contained in:
tangly
2022-11-18 11:44:12 +08:00
parent 12babbdbca
commit b4398e516e
5 changed files with 38 additions and 3 deletions

View File

@@ -79,6 +79,7 @@ async function getPageProperties(id, block, schema, authToken, tagOptions, siteI
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.pageIcon = getPageIcon(id, block) ?? ''
properties.page_cover = getPostCover(id, block) ?? siteInfo?.pageCover
properties.content = value.content ?? []
properties.tagItems = properties?.tags?.map(tag => {
@@ -97,4 +98,13 @@ async function getPageProperties(id, block, schema, authToken, tagOptions, siteI
}
}
function getPageIcon(id, block) {
const pageIcon = block[id].value?.format?.page_icon
if (pageIcon) {
if (pageIcon.startsWith('/')) return 'https://www.notion.so' + pageIcon
if (pageIcon.startsWith('http')) return defaultMapImageUrl(pageIcon, block[id].value)
return pageIcon
}
}
export { getPageProperties as default }