-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reactive
lang
when using Nuxt I18n
- Loading branch information
Showing
6 changed files
with
47 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
import { applyDefaults as setup } from '../logic/applyDefaults' | ||
import { applyDefaults } from '../logic/applyDefaults' | ||
import { | ||
defineNuxtPlugin, | ||
ref, | ||
useSiteConfig, | ||
} from '#imports' | ||
|
||
export default defineNuxtPlugin({ | ||
name: 'nuxt-seo:defaults', | ||
order: 999, | ||
env: { | ||
islands: false, | ||
}, | ||
setup, | ||
setup() { | ||
const siteConfig = useSiteConfig() | ||
const locale = ref(siteConfig.currentLocale || siteConfig.defaultLocale) | ||
applyDefaults({ | ||
locale, | ||
}) | ||
// TODO reactive locale, need upstream fixes to nuxt-site-config | ||
}, | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { applyDefaults } from '../logic/applyDefaults' | ||
import { defineNuxtPlugin, ref } from '#imports' | ||
|
||
export default defineNuxtPlugin({ | ||
name: 'nuxt-seo:defaults', | ||
env: { | ||
islands: false, | ||
}, | ||
// we need to wait for the i18n plugin to run first | ||
// @ts-expect-error dynamic | ||
dependsOn: import.meta.server | ||
? [ | ||
'nuxt-site-config:i18n', | ||
] | ||
: [], | ||
setup(nuxtApp) { | ||
const locale = ref(nuxtApp.$i18n!.locale.value) | ||
// @ts-expect-error untyped | ||
nuxtApp.hook('i18n:localeSwitched', ({ newLocale }) => { | ||
locale.value = newLocale | ||
}) | ||
applyDefaults({ locale }) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters