(fix) ページの言語が正しく認識されるように

This commit is contained in:
kakkokari-gtyih 2023-11-22 20:06:12 +09:00
parent 4b611c964b
commit 325a3ca5dc

View File

@ -1,8 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import type { LocaleObject } from '@nuxtjs/i18n/dist/runtime/composables';
import NProgress from 'nprogress'; import NProgress from 'nprogress';
import type { Graph, Thing } from 'schema-dts'; import type { Graph, Thing } from 'schema-dts';
const { t, locale } = useI18n(); const { t, locale, locales } = useI18n();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const colorMode = useColorMode(); const colorMode = useColorMode();
@ -66,6 +67,7 @@ const getLdJson = (additionalGraphes: Thing[] = []): string => {
ldJson['@graph'] = ldJson['@graph'].concat(additionalGraphes); ldJson['@graph'] = ldJson['@graph'].concat(additionalGraphes);
return JSON.stringify(ldJson); return JSON.stringify(ldJson);
}; };
const currentLocaleIso = computed(() => (locales.value as LocaleObject[]).find((e) => e?.code === locale.value)?.iso);
const head = useLocaleHead({ const head = useLocaleHead({
addSeoAttributes: true addSeoAttributes: true
@ -87,7 +89,7 @@ const cnHead = (locale.value === 'cn') ? [
useHead((): Record<string, any> => ({ useHead((): Record<string, any> => ({
htmlAttrs: { htmlAttrs: {
lang: locale.value, lang: currentLocaleIso.value,
'data-bs-theme': colorMode.value, 'data-bs-theme': colorMode.value,
}, },
title: getTitle(), title: getTitle(),