Skip to content

Commit 8116353

Browse files
committed
fix: wait for i18n plugin, handle fallback
Fixes #286
1 parent b5f3aa7 commit 8116353

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/runtime/nuxt/plugin/defaultsWaitI18n.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { applyDefaults } from '../logic/applyDefaults'
2-
import { defineNuxtPlugin, ref } from '#imports'
2+
import { defineNuxtPlugin, ref, useSiteConfig } from '#imports'
33

44
export default defineNuxtPlugin({
55
name: 'nuxt-seo:defaults',
@@ -12,9 +12,12 @@ export default defineNuxtPlugin({
1212
? [
1313
'nuxt-site-config:i18n',
1414
]
15-
: [],
15+
: [
16+
'i18n:plugin',
17+
],
1618
setup(nuxtApp) {
17-
const locale = ref(nuxtApp.$i18n!.locale.value)
19+
const siteConfig = useSiteConfig()
20+
const locale = ref(nuxtApp.$i18n?.locale?.value || siteConfig.currentLocale || siteConfig.defaultLocale)
1821
// @ts-expect-error untyped
1922
nuxtApp.hook('i18n:localeSwitched', ({ newLocale }) => {
2023
locale.value = newLocale

0 commit comments

Comments
 (0)