Merge pull request #3326 from tangly1024/fix/iconfont

Fix/iconfont
This commit is contained in:
tangly1024
2025-04-11 22:37:48 +08:00
committed by GitHub
6 changed files with 43 additions and 63 deletions

View File

@@ -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 => {