From 28187dc59828e2a468aa5f03fa1a89ba212162b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=B2=AB=E8=8A=B1=E7=81=ABzzz=F0=9F=8C=99?= Date: Thu, 22 Jan 2026 12:43:39 +0800 Subject: [PATCH 1/6] Fix i18n code logic --- layer/content.config.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/layer/content.config.ts b/layer/content.config.ts index b0b9bb80b..5ae63c50f 100644 --- a/layer/content.config.ts +++ b/layer/content.config.ts @@ -21,9 +21,10 @@ let collections: Record if (locales && Array.isArray(locales)) { collections = {} for (const locale of locales) { - const code = (typeof locale === 'string' ? locale : locale.code).replace('-', '_') + const code = (typeof locale === 'string' ? locale : locale.code) + const safeCode = code.replace('-', '_') - collections[`landing_${code}`] = defineCollection({ + collections[`landing_${safeCode}`] = defineCollection({ type: 'page', source: { cwd, @@ -31,7 +32,7 @@ if (locales && Array.isArray(locales)) { }, }) - collections[`docs_${code}`] = defineCollection({ + collections[`docs_${safeCode}`] = defineCollection({ type: 'page', source: { cwd, From b758a08a122ba7040e1f7636b841d59c5ee7e37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=B2=AB=E8=8A=B1=E7=81=ABzzz=F0=9F=8C=99?= Date: Thu, 22 Jan 2026 13:03:58 +0800 Subject: [PATCH 2/6] Fix queryCollection --- layer/app/pages/[[lang]]/[...slug].vue | 4 +++- layer/app/templates/landing.vue | 3 ++- layer/app/utils/locale.ts | 3 +++ layer/server/utils/content.ts | 7 ++++--- layer/server/utils/locale.ts | 3 +++ 5 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 layer/app/utils/locale.ts create mode 100644 layer/server/utils/locale.ts diff --git a/layer/app/pages/[[lang]]/[...slug].vue b/layer/app/pages/[[lang]]/[...slug].vue index e2f1768d8..fcf6c0937 100644 --- a/layer/app/pages/[[lang]]/[...slug].vue +++ b/layer/app/pages/[[lang]]/[...slug].vue @@ -3,6 +3,8 @@ import { kebabCase } from 'scule' import type { ContentNavigationItem, Collections, DocsCollectionItem } from '@nuxt/content' import { findPageHeadline } from '@nuxt/content/utils' +import { safeLocaleCode } from '~/utils/locale' + definePageMeta({ layout: 'docs', }) @@ -12,7 +14,7 @@ const { locale, isEnabled, t } = useDocusI18n() const appConfig = useAppConfig() const navigation = inject>('navigation') -const collectionName = computed(() => isEnabled.value ? `docs_${locale.value}` : 'docs') +const collectionName = computed(() => isEnabled.value ? `docs_${safeLocaleCode(locale.value)}` : 'docs') const [{ data: page }, { data: surround }] = await Promise.all([ useAsyncData(kebabCase(route.path), () => queryCollection(collectionName.value as keyof Collections).path(route.path).first() as Promise), diff --git a/layer/app/templates/landing.vue b/layer/app/templates/landing.vue index c77ef1160..295659dca 100644 --- a/layer/app/templates/landing.vue +++ b/layer/app/templates/landing.vue @@ -1,11 +1,12 @@