From 622594a307013313ff605f8c94272b69d33f1793 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 13 May 2024 12:15:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=85=E9=93=BE=E8=87=AA=E5=8A=A8=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/notion/mapPageUrl.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/notion/mapPageUrl.js b/lib/notion/mapPageUrl.js index 8a7bc73c..80fe70d8 100644 --- a/lib/notion/mapPageUrl.js +++ b/lib/notion/mapPageUrl.js @@ -12,13 +12,13 @@ export const mapPageUrl = allPages => { const allAnchorTags = document.getElementsByTagName('a') // 或者使用 document.querySelectorAll('a') 获取 NodeList for (const anchorTag of allAnchorTags) { // 检查url - if (anchorTag.href) { + if (anchorTag?.href) { // 如果url是一个Notion_id,尝试匹配成博客的文章内链 const slug = getLastPartOfUrl(anchorTag.href) if (checkStrIsNotionId(slug)) { - const slugPage = allPages.find(page => uuidToId(page.id) === slug) + const slugPage = allPages?.find(page => uuidToId(page.id) === slug) if (slugPage) { - anchorTag.href = slugPage.href + anchorTag.href = slugPage?.href } } }