From 543f6ea66f5cda000b83b242199cf7e249983a78 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Mon, 26 Aug 2024 13:38:11 +0800 Subject: [PATCH 1/2] perf(theme): redirect locales page --- theme/src/client/composables/langs.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/theme/src/client/composables/langs.ts b/theme/src/client/composables/langs.ts index 7aee9516..169b2f01 100644 --- a/theme/src/client/composables/langs.ts +++ b/theme/src/client/composables/langs.ts @@ -3,7 +3,6 @@ import { computed } from 'vue' import { normalizeLink } from '../utils/index.js' import { useThemeData } from './theme-data.js' import { useData } from './data.js' -import { getSidebarFirstLink, useSidebarData } from './sidebar.js' import { useBlogPageData } from './page.js' export function useLangs({ @@ -12,7 +11,6 @@ export function useLangs({ const theme = useThemeData() const { page } = useData() const routeLocale = useRouteLocale() - const sidebar = useSidebarData() const { isBlogPost } = useBlogPageData() const currentLang = computed(() => { @@ -24,7 +22,10 @@ export function useLangs({ }) const getPageLink = (locale: string) => { - const pagePath = page.value.path.slice(routeLocale.value.length) + const filepath = page.value.filePathRelative + ? `/${page.value.filePathRelative}` + : page.value.path + const pagePath = filepath.slice(routeLocale.value.length) const targetPath = normalizeLink(locale, pagePath) const { notFound, path } = resolveRoute(targetPath) if (!notFound) @@ -34,14 +35,6 @@ export function useLangs({ if (isBlogPost.value && blog !== false) return withBase(blog?.link || normalizeLink(locale, 'blog/')) - const sidebarList = sidebar.value - - if (sidebarList.length > 0) { - const link = getSidebarFirstLink(sidebarList) - if (link) - return link - } - const home = withBase(theme.value.home || '/') const fallbackResolve = resolveRoute(withBase(locale)) return fallbackResolve.notFound ? home : fallbackResolve.path From b55a0f754682b5a295ae034dbf870c677ac28ae8 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Mon, 26 Aug 2024 13:39:53 +0800 Subject: [PATCH 2/2] fix(theme): incorrect notes auto frontmatter permalink --- theme/src/node/autoFrontmatter/resolveOptions.ts | 2 +- theme/src/node/theme.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/theme/src/node/autoFrontmatter/resolveOptions.ts b/theme/src/node/autoFrontmatter/resolveOptions.ts index 3b47f548..1d7477a8 100644 --- a/theme/src/node/autoFrontmatter/resolveOptions.ts +++ b/theme/src/node/autoFrontmatter/resolveOptions.ts @@ -147,7 +147,7 @@ export function resolveOptions( const note = findNote(relativePath) const prefix = notes?.link || '' const args: string[] = [ - locale, + prefix.startsWith(locale) ? '/' : locale, prefix, note?.link || '', ] diff --git a/theme/src/node/theme.ts b/theme/src/node/theme.ts index e7834a72..c56c62c4 100644 --- a/theme/src/node/theme.ts +++ b/theme/src/node/theme.ts @@ -78,6 +78,7 @@ export function plumeTheme(options: PlumeThemeOptions = {}): Theme { await prepareData(app) }) const { localeOptions } = await waitForConfigLoaded() + await waitForAutoFrontmatter() await prepareThemeData(app, localeOptions) await prepareData(app) },