Skip to content

Commit

Permalink
page inner links
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed May 20, 2024
1 parent 45009c9 commit 8df65b7
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions lib/notion/convertInnerUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@ export const convertInnerUrl = allPages => {
}
}

if (anchorTag?.target === '_blank') {
const hrefWithoutQueryHash = anchorTag.href.split('?')[0].split('#')[0]
const hrefWithRelativeHash =
currentURL.split('#')[0] + anchorTag.href.split('#')[1]

if (
currentURL === hrefWithoutQueryHash ||
currentURL === hrefWithRelativeHash
) {
anchorTag.target = '_self'
for (const anchorTag of allAnchorTags) {
if (anchorTag?.target === '_blank') {
const hrefWithoutQueryHash = anchorTag.href
.split('?')[0]
.split('#')[0]
const hrefWithRelativeHash =
currentURL.split('#')[0] || '' + anchorTag.href.split('#')[1] || ''
if (
currentURL === hrefWithoutQueryHash ||
currentURL === hrefWithRelativeHash
) {
anchorTag.target = '_self'
}
}
}
}
Expand Down

0 comments on commit 8df65b7

Please sign in to comment.