Skip to content

Commit

Permalink
chore: use import.meta build flags
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Sep 8, 2023
1 parent 3943994 commit f5eeaec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions plugins/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ export default defineNuxtPlugin(async (nuxtApp) => {
const { locale } = i18n

// Initially load the site data
if (process.server) {
if (import.meta.server) {
await updateSite()
}

// Update the site data on locale change
if (process.client) {
if (import.meta.client) {
i18n.onBeforeLanguageSwitch = async (
oldLocale: string,
newLocale: string,
) => {
if (oldLocale !== newLocale) {
if (process.dev)
if (import.meta.dev)
console.log('Locale changed:', oldLocale, '->', newLocale)

await updateSite()
Expand Down
4 changes: 2 additions & 2 deletions utils/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export function getLocalePreference() {
let fullLocale: string | undefined
let languageCode: string | undefined

if (process.server) {
if (import.meta.server) {
const requestHeaders = useRequestHeaders()
fullLocale = requestHeaders['accept-language']
languageCode = fullLocale?.split(',')[0]?.slice(0, 2)
} else if (process.client) {
} else if (import.meta.client) {
fullLocale = navigator.language
languageCode = fullLocale?.slice(0, 2)
}
Expand Down

0 comments on commit f5eeaec

Please sign in to comment.