mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-07 23:16:52 +00:00
@@ -1,4 +1,3 @@
|
||||
import { loadLangFromLocalStorage } from '@/lib/lang'
|
||||
import { idToUuid } from 'notion-utils'
|
||||
import { checkStrIsNotionId, getLastPartOfUrl, isBrowser } from '../utils'
|
||||
|
||||
@@ -7,7 +6,7 @@ import { checkStrIsNotionId, getLastPartOfUrl, isBrowser } from '../utils'
|
||||
* 1.若是本站域名,则在当前窗口打开、不开新窗口
|
||||
* 2.url是notion-id,转成站内文章链接
|
||||
*/
|
||||
export const convertInnerUrl = allPages => {
|
||||
export const convertInnerUrl = ({ allPages, lang }) => {
|
||||
if (!isBrowser) {
|
||||
return
|
||||
}
|
||||
@@ -18,11 +17,9 @@ export const convertInnerUrl = allPages => {
|
||||
if (!allAnchorTags) {
|
||||
return
|
||||
}
|
||||
|
||||
const { origin, pathname } = window.location
|
||||
const currentURL = origin + pathname
|
||||
const currentPathLang = pathname.split('/').filter(Boolean)[0]
|
||||
const lang = loadLangFromLocalStorage().split(/[-_]/)[0]
|
||||
const langPrefix = lang === currentPathLang ? '/' + lang : ''
|
||||
for (const anchorTag of allAnchorTags) {
|
||||
// url替换成slug
|
||||
@@ -56,6 +53,7 @@ export const convertInnerUrl = allPages => {
|
||||
anchorTag.target = '_blank'
|
||||
}
|
||||
}
|
||||
|
||||
for (const anchorTag of allAnchorTags) {
|
||||
const slug = getLastPartOfUrl(anchorTag.href)
|
||||
const slugPage = allPages?.find(page => {
|
||||
|
||||
Reference in New Issue
Block a user