From b52f81815461bd428ce8759978da79ebc12205e6 Mon Sep 17 00:00:00 2001 From: anime Date: Wed, 9 Jul 2025 13:11:52 +0800 Subject: [PATCH] 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. --- lib/notion/getPageContentText.js | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/lib/notion/getPageContentText.js b/lib/notion/getPageContentText.js index 20c5a451..fa93c9a8 100644 --- a/lib/notion/getPageContentText.js +++ b/lib/notion/getPageContentText.js @@ -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