mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
feat(getPageContentText): add null checks for block references
- Add validation for transclusion reference pointer existence - Return empty string when block is not found - Prevent potential errors from undefined block references
This commit is contained in:
@@ -56,7 +56,7 @@ export function getPageContentText(post, pageBlockMap) {
|
||||
const result = []
|
||||
const blockPointer = block.format.transclusion_reference_pointer
|
||||
const blockPointerId = blockPointer.id
|
||||
if (blockPointer) {
|
||||
if (blockPointer && pageBlockMap.block[blockPointerId].value) {
|
||||
const blockContentList = pageBlockMap.block[blockPointerId].value.content
|
||||
for (const blockContent of blockContentList) {
|
||||
result.push(getBlockContentText(blockContent))
|
||||
@@ -67,6 +67,9 @@ export function getPageContentText(post, pageBlockMap) {
|
||||
|
||||
function getBlockContentText(id) {
|
||||
const block = pageBlockMap?.block[id].value
|
||||
if (!block) {
|
||||
return ''
|
||||
}
|
||||
const blockType = block.type
|
||||
// todo: 处理更多类型
|
||||
switch (blockType) {
|
||||
|
||||
Reference in New Issue
Block a user