1
+ import { loadLangFromLocalStorage } from '@/lib/lang'
1
2
import { idToUuid } from 'notion-utils'
2
3
import { checkStrIsNotionId , getLastPartOfUrl , isBrowser } from '../utils'
3
- import { loadLangFromLocalStorage } from '@/lib/lang'
4
4
5
5
/**
6
6
* 处理页面内连接跳转:
@@ -13,12 +13,13 @@ export const convertInnerUrl = allPages => {
13
13
}
14
14
const allAnchorTags = document
15
15
?. getElementById ( 'notion-article' )
16
- ?. querySelectorAll ( 'a.notion-link' )
16
+ ?. querySelectorAll ( 'a.notion-link, a.notion-collection-card ' )
17
17
18
18
if ( ! allAnchorTags ) {
19
19
return
20
20
}
21
- const { origin, pathname } = window . location ;
21
+
22
+ const { origin, pathname } = window . location
22
23
const currentURL = origin + pathname
23
24
const currentPathLang = pathname . split ( '/' ) . filter ( Boolean ) [ 0 ]
24
25
const lang = loadLangFromLocalStorage ( ) . split ( / [ - _ ] / ) [ 0 ]
@@ -49,5 +50,18 @@ export const convertInnerUrl = allPages => {
49
50
anchorTag . target = '_self'
50
51
}
51
52
}
53
+
54
+ // 如果链接以#号结尾,则强制在新窗口打开
55
+ if ( anchorTag . href . endsWith ( '#' ) ) {
56
+ anchorTag . target = '_blank'
57
+ }
58
+ }
59
+ for ( const anchorTag of allAnchorTags ) {
60
+ const slug = getLastPartOfUrl ( anchorTag . href )
61
+ const slugPage = allPages ?. find ( page => {
62
+ return page . slug . indexOf ( slug ) >= 0
63
+ } )
64
+ if ( slugPage ) {
65
+ }
52
66
}
53
- }
67
+ }
0 commit comments