fix(theme): incorrect langs switch in blog page, close #404 (#405)

This commit is contained in:
pengzhanbo 2024-12-29 00:39:14 +08:00 committed by GitHub
parent 0205ec8681
commit 8dff33a481
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,6 @@
import { computed } from 'vue'
import { resolveRoute, useRouteLocale } from 'vuepress/client'
import { removeLeadingSlash } from 'vuepress/shared'
import { normalizeLink } from '../utils/index.js'
import { useData } from './data.js'
import { useBlogPageData } from './page.js'
@ -41,7 +42,7 @@ export function useLangs({
// fallback to blog
const blog = theme.value.blog
if (isBlogPost.value && blog !== false)
return blog?.link || normalizeLink(locale, 'blog/')
return normalizeLink(locale, removeLeadingSlash(blog?.link || 'blog/'))
// fallback to home
const home = theme.value.home || '/'