Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/db/SiteDataApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ async function convertNotionToSiteData(SITE_DATABASE_PAGE_ID, from, pageRecordMa
})

// 站点基础信息
const siteInfo = getSiteInfo({ collection, block, NOTION_CONFIG })
const siteInfo = getSiteInfo({ collection, block, rawMetadata, NOTION_CONFIG })

// 文章计数
let postCount = 0
Expand Down Expand Up @@ -767,7 +767,7 @@ function getCategoryOptions(schema) {
* @param from
* @returns {Promise<{title,description,pageCover,icon}>}
*/
function getSiteInfo({ collection, block, NOTION_CONFIG }) {
function getSiteInfo({ collection, block, rawMetadata, NOTION_CONFIG }) {
const defaultTitle = NOTION_CONFIG?.TITLE || 'NotionNext BLOG'
const defaultDescription =
NOTION_CONFIG?.DESCRIPTION || '这是一个由NotionNext生成的站点'
Expand All @@ -790,9 +790,15 @@ function getSiteInfo({ collection, block, NOTION_CONFIG }) {
? Object.assign(collection).description[0][0]
: defaultDescription

// 站点封面优先级:
// 1. 数据库 collection.cover
// 2. 数据库页面(collection_view_page)自身的 page_cover
// 3. HOME_BANNER_IMAGE / 默认兜底图
const pageCover = collection?.cover
? mapImgUrl(collection?.cover, collection, 'collection')
: defaultPageCover
: rawMetadata?.format?.page_cover
? mapImgUrl(rawMetadata?.format?.page_cover, rawMetadata, 'block')
: defaultPageCover

// 用户头像压缩一下
let icon = compressImage(
Expand Down Expand Up @@ -985,4 +991,4 @@ export function getNavPages({ allPages }) {
publishDate: item.publishDate,
ext: item.ext || {}
}))
}
}