mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-18 15:09:34 +00:00
fix lang
This commit is contained in:
12
lib/lang.js
12
lib/lang.js
@@ -121,14 +121,4 @@ export const redirectUserLang = (lang, pageId) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前 Next.js 路由下的 locale
|
||||
* @returns 当前路由下的 locale
|
||||
*/
|
||||
export function getCurrentLang() {
|
||||
const router = useRouter()
|
||||
let currentLang = router.locale
|
||||
return currentLang
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
import { idToUuid } from 'notion-utils'
|
||||
import { checkStrIsNotionId, getLastPartOfUrl, isBrowser } from '../utils'
|
||||
import { getCurrentLang } from '@/lib/lang'
|
||||
import BLOG from '@/blog.config'
|
||||
|
||||
/**
|
||||
* 处理页面内连接跳转:
|
||||
* 1.若是本站域名,则在当前窗口打开、不开新窗口
|
||||
* 2.url是notion-id,转成站内文章链接
|
||||
*/
|
||||
export const convertInnerUrl = allPages => {
|
||||
export const convertInnerUrl = ({allPages,lang}) => {
|
||||
if (!isBrowser) {
|
||||
return
|
||||
}
|
||||
@@ -21,7 +22,6 @@ export const convertInnerUrl = allPages => {
|
||||
const { origin, pathname } = window.location
|
||||
const currentURL = origin + pathname
|
||||
const currentPathLang = pathname.split('/').filter(Boolean)[0]
|
||||
const lang = getCurrentLang
|
||||
const langPrefix = lang === currentPathLang ? '/' + lang : ''
|
||||
for (const anchorTag of allAnchorTags) {
|
||||
// url替换成slug
|
||||
|
||||
Reference in New Issue
Block a user