mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
优化:更多站点信息支持Notion_config配置
This commit is contained in:
@@ -237,38 +237,43 @@ function getCategoryOptions(schema) {
|
||||
* @returns {Promise<{title,description,pageCover,icon}>}
|
||||
*/
|
||||
function getSiteInfo({ collection, block, NOTION_CONFIG, pageId }) {
|
||||
const defaultTitle = siteConfig('TITLE', '', NOTION_CONFIG)
|
||||
const defaultDescription = siteConfig('DESCRIPTION', '', NOTION_CONFIG)
|
||||
const defaultPageCover = siteConfig('HOME_BANNER_IMAGE', '', NOTION_CONFIG)
|
||||
const defaultIcon = siteConfig('AVATAR', '', NOTION_CONFIG)
|
||||
const defaultLink = siteConfig('LINK', '', NOTION_CONFIG)
|
||||
if (!collection && !block) {
|
||||
return {
|
||||
title: BLOG.TITLE,
|
||||
description: BLOG.DESCRIPTION,
|
||||
pageCover: BLOG.HOME_BANNER_IMAGE,
|
||||
icon: BLOG.AVATAR,
|
||||
link: BLOG.LINK
|
||||
title: defaultTitle,
|
||||
description: defaultDescription,
|
||||
pageCover: defaultPageCover,
|
||||
icon: defaultIcon,
|
||||
link: defaultLink
|
||||
}
|
||||
}
|
||||
|
||||
const title = collection?.name?.[0][0] || BLOG.TITLE
|
||||
const title = collection?.name?.[0][0] || defaultTitle
|
||||
const description = collection?.description
|
||||
? Object.assign(collection).description[0][0]
|
||||
: BLOG.DESCRIPTION
|
||||
: defaultDescription
|
||||
|
||||
const pageCover = collection?.cover
|
||||
? mapImgUrl(collection?.cover, collection, 'collection')
|
||||
: BLOG.HOME_BANNER_IMAGE
|
||||
: defaultPageCover
|
||||
|
||||
// 用户头像压缩一下
|
||||
let icon = compressImage(
|
||||
collection?.icon
|
||||
? mapImgUrl(collection?.icon, collection, 'collection')
|
||||
: BLOG.AVATAR
|
||||
: defaultIcon
|
||||
)
|
||||
// 站点网址
|
||||
const link = NOTION_CONFIG?.LINK || BLOG.LINK
|
||||
const link = NOTION_CONFIG?.LINK || defaultLink
|
||||
|
||||
// 站点图标不能是emoji
|
||||
const emojiPattern = /\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g
|
||||
if (!icon || emojiPattern.test(icon)) {
|
||||
icon = BLOG.AVATAR
|
||||
icon = defaultIcon
|
||||
}
|
||||
return { title, description, pageCover, icon, link }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user