mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-19 23:16:48 +00:00
内链自动替换
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user