mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
封面图支持外部链接和上传
This commit is contained in:
@@ -2,6 +2,7 @@ import BLOG from '@/blog.config'
|
||||
import { getDataFromCache, setDataToCache } from '@/lib/cache/cache_manager'
|
||||
import { getPostBlocks } from '@/lib/notion/getPostBlocks'
|
||||
import { idToUuid } from 'notion-utils'
|
||||
import { defaultMapImageUrl } from 'react-notion-x'
|
||||
import { getAllCategories } from './getAllCategories'
|
||||
import { getAllPosts, getAllPostCount } from './getAllPosts'
|
||||
import { getAllTags } from './getAllTags'
|
||||
@@ -158,7 +159,7 @@ async function getBlogInfo ({ notionPageData, from }) {
|
||||
const collection = notionPageData?.collection
|
||||
const title = collection?.name[0][0] || BLOG.TITLE
|
||||
const description = collection?.description[0][0] || BLOG.DESCRIPTION
|
||||
const pageCover = mapCoverUrl(collection?.cover)
|
||||
const pageCover = mapCoverUrl(collection?.cover, notionPageData.block)
|
||||
return { title, description, pageCover }
|
||||
}
|
||||
|
||||
@@ -167,14 +168,13 @@ async function getBlogInfo ({ notionPageData, from }) {
|
||||
* @param pageCover
|
||||
* @returns {string}
|
||||
*/
|
||||
const mapCoverUrl = pageCover => {
|
||||
const mapCoverUrl = (pageCover, block) => {
|
||||
if (!pageCover || pageCover === '') {
|
||||
return BLOG.HOME_BANNER_IMAGE
|
||||
}
|
||||
if (pageCover.indexOf('/images') === 0) {
|
||||
return 'https://www.notion.so' + pageCover
|
||||
} else {
|
||||
return pageCover
|
||||
if (pageCover) {
|
||||
if (pageCover.startsWith('/')) return 'https://www.notion.so' + pageCover
|
||||
if (pageCover.startsWith('http')) return defaultMapImageUrl(pageCover, block[idToUuid(BLOG.NOTION_PAGE_ID)].value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user