mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-13 23:16:47 +00:00
gallery视图自动替换url
This commit is contained in:
@@ -165,7 +165,7 @@ const ExternalPlugin = props => {
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
// 映射url
|
||||
// 将notion-id格式的url转成自定义slug
|
||||
convertInnerUrl(props?.allNavPages)
|
||||
}, 500)
|
||||
}, [router])
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { loadLangFromLocalStorage } from '@/lib/lang'
|
||||
import { idToUuid } from 'notion-utils'
|
||||
import { checkStrIsNotionId, getLastPartOfUrl, isBrowser } from '../utils'
|
||||
import { loadLangFromLocalStorage } from '@/lib/lang'
|
||||
|
||||
/**
|
||||
* 处理页面内连接跳转:
|
||||
@@ -13,12 +13,13 @@ export const convertInnerUrl = allPages => {
|
||||
}
|
||||
const allAnchorTags = document
|
||||
?.getElementById('notion-article')
|
||||
?.querySelectorAll('a.notion-link')
|
||||
?.querySelectorAll('a.notion-link, a.notion-collection-card')
|
||||
|
||||
if (!allAnchorTags) {
|
||||
return
|
||||
}
|
||||
const { origin, pathname } = window.location;
|
||||
|
||||
const { origin, pathname } = window.location
|
||||
const currentURL = origin + pathname
|
||||
const currentPathLang = pathname.split('/').filter(Boolean)[0]
|
||||
const lang = loadLangFromLocalStorage().split(/[-_]/)[0]
|
||||
@@ -49,5 +50,18 @@ export const convertInnerUrl = allPages => {
|
||||
anchorTag.target = '_self'
|
||||
}
|
||||
}
|
||||
|
||||
// 如果链接以#号结尾,则强制在新窗口打开
|
||||
if (anchorTag.href.endsWith('#')) {
|
||||
anchorTag.target = '_blank'
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const anchorTag of allAnchorTags) {
|
||||
const slug = getLastPartOfUrl(anchorTag.href)
|
||||
const slugPage = allPages?.find(page => {
|
||||
return page.slug.indexOf(slug) >= 0
|
||||
})
|
||||
if (slugPage) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user