mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-01 23:16:51 +00:00
@@ -2,6 +2,7 @@ import BLOG from '@/blog.config'
|
|||||||
import { getDataFromCache, setDataToCache } from '@/lib/cache/cache_manager'
|
import { getDataFromCache, setDataToCache } from '@/lib/cache/cache_manager'
|
||||||
import { getPostBlocks } from '@/lib/notion/getPostBlocks'
|
import { getPostBlocks } from '@/lib/notion/getPostBlocks'
|
||||||
import { idToUuid } from 'notion-utils'
|
import { idToUuid } from 'notion-utils'
|
||||||
|
import { defaultMapImageUrl } from 'react-notion-x'
|
||||||
import { getAllCategories } from './getAllCategories'
|
import { getAllCategories } from './getAllCategories'
|
||||||
import { getAllPosts, getAllPostCount } from './getAllPosts'
|
import { getAllPosts, getAllPostCount } from './getAllPosts'
|
||||||
import { getAllTags } from './getAllTags'
|
import { getAllTags } from './getAllTags'
|
||||||
@@ -158,7 +159,7 @@ async function getBlogInfo ({ notionPageData, from }) {
|
|||||||
const collection = notionPageData?.collection
|
const collection = notionPageData?.collection
|
||||||
const title = collection?.name[0][0] || BLOG.TITLE
|
const title = collection?.name[0][0] || BLOG.TITLE
|
||||||
const description = collection?.description[0][0] || BLOG.DESCRIPTION
|
const description = collection?.description[0][0] || BLOG.DESCRIPTION
|
||||||
const pageCover = mapCoverUrl(collection?.cover)
|
const pageCover = mapCoverUrl(collection?.cover, notionPageData.block)
|
||||||
return { title, description, pageCover }
|
return { title, description, pageCover }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,14 +168,13 @@ async function getBlogInfo ({ notionPageData, from }) {
|
|||||||
* @param pageCover
|
* @param pageCover
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
const mapCoverUrl = pageCover => {
|
const mapCoverUrl = (pageCover, block) => {
|
||||||
if (!pageCover || pageCover === '') {
|
if (!pageCover || pageCover === '') {
|
||||||
return BLOG.HOME_BANNER_IMAGE
|
return BLOG.HOME_BANNER_IMAGE
|
||||||
}
|
}
|
||||||
if (pageCover.indexOf('/images') === 0) {
|
if (pageCover) {
|
||||||
return 'https://www.notion.so' + pageCover
|
if (pageCover.startsWith('/')) return 'https://www.notion.so' + pageCover
|
||||||
} else {
|
if (pageCover.startsWith('http')) return defaultMapImageUrl(pageCover, block[idToUuid(BLOG.NOTION_PAGE_ID)].value)
|
||||||
return pageCover
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user