From 8dff33a4811421ea2d5cc56361b5873c171fc451 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Sun, 29 Dec 2024 00:39:14 +0800 Subject: [PATCH] fix(theme): incorrect langs switch in blog page, close #404 (#405) --- theme/src/client/composables/langs.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/theme/src/client/composables/langs.ts b/theme/src/client/composables/langs.ts index 76ade41e..ee165e57 100644 --- a/theme/src/client/composables/langs.ts +++ b/theme/src/client/composables/langs.ts @@ -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 || '/'