feat(getPageContentText): replace custom text extraction with notion-utils

The getTextContent function was removed and replaced with an import from
notion-utils, simplifying the text extraction logic for Notion page
content. This change removes the custom recursive implementation and
uses the standardized utility function instead.
This commit is contained in:
anime
2025-07-09 13:11:52 +08:00
parent d22e8bb177
commit b52f818154

View File

@@ -1,4 +1,4 @@
import { checkStrIsUuid, isIterable } from '@/lib/utils'
import { getTextContent } from 'notion-utils'
export function getPageContentText(post, pageBlockMap) {
/**
@@ -24,34 +24,6 @@ export function getPageContentText(post, pageBlockMap) {
return ''
}
// todo: 清除更多无用标签
const removeTypeFlag = ['a', 'p', '‣']
/**
* 递归获取层层嵌套的数组
* @param {*} textArray
* @returns string
*/
function getTextContent(textArray) {
if (typeof textArray === 'object' && isIterable(textArray)) {
let result = ''
for (const textObj of textArray) {
if (textArray.length > 1 && removeTypeFlag.includes(textArray[0])) {
return result
}
result = result + getTextContent(textObj)
}
return result
} else if (typeof textArray === 'string') {
if (checkStrIsUuid(textArray) && pageBlockMap.block[textArray]) {
return getBlockContentText(textArray)
} else if (textArray === pageBlockMap.block[postId].value.space_id) {
return ''
}
return textArray
}
}
function getTransclusionReference(block) {
const result = []
const blockPointer = block.format.transclusion_reference_pointer