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 } } }