mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
fix(修复getPost 时异常值导致的500和无法正确渲染问题):
(cherry picked from commit cc3d0f81f93832c8671e8a48cd49c966ab8b279b)
This commit is contained in:
@@ -3,6 +3,7 @@ import { idToUuid } from 'notion-utils'
|
||||
import { defaultMapImageUrl } from 'react-notion-x'
|
||||
import formatDate from '../utils/formatDate'
|
||||
import { getPage } from './getPostBlocks'
|
||||
import { checkStrIsNotionId, checkStrIsUuid } from '@/lib/utils'
|
||||
|
||||
/**
|
||||
* 根据页面ID获取内容
|
||||
@@ -14,14 +15,22 @@ export async function getPost(pageId) {
|
||||
if (!blockMap) {
|
||||
return null
|
||||
}
|
||||
|
||||
const postInfo = blockMap?.block?.[idToUuid(pageId)].value
|
||||
if (checkStrIsNotionId(pageId)) {
|
||||
pageId = idToUuid(pageId)
|
||||
}
|
||||
if (!checkStrIsUuid(pageId)) {
|
||||
return null
|
||||
}
|
||||
const postInfo = blockMap?.block?.[pageId]?.value
|
||||
if (!postInfo) {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
id: pageId,
|
||||
type: postInfo,
|
||||
type: postInfo.type,
|
||||
category: '',
|
||||
tags: [],
|
||||
title: postInfo?.properties?.title?.[0],
|
||||
title: postInfo?.properties?.title?.[0] || null,
|
||||
status: 'Published',
|
||||
createdTime: formatDate(
|
||||
new Date(postInfo.created_time).toString(),
|
||||
@@ -32,7 +41,7 @@ export async function getPost(pageId) {
|
||||
BLOG.LANG
|
||||
),
|
||||
fullWidth: postInfo?.fullWidth || false,
|
||||
page_cover: getPageCover(postInfo) || BLOG.HOME_BANNER_IMAGE,
|
||||
page_cover: getPageCover(postInfo) || BLOG.HOME_BANNER_IMAGE || null,
|
||||
date: {
|
||||
start_date: formatDate(
|
||||
new Date(postInfo?.last_edited_time).toString(),
|
||||
|
||||
Reference in New Issue
Block a user