Skip to content

Commit 710d4c1

Browse files
authored
fix: use serialized value of nuxt.options.pages for compatibility (#3387)
1 parent 7745510 commit 710d4c1

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/context.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export interface I18nNuxtContext {
1717
isSSG: boolean
1818
isBuild: boolean
1919
isTest: boolean
20-
pages: boolean
20+
// serialized boolean value
21+
hasPages: string
2122
normalizedLocales: LocaleObject<string>[]
2223
localeCodes: string[]
2324
localeInfo: LocaleInfo[]
@@ -43,9 +44,9 @@ export function createContext(userOptions: NuxtI18nOptions, nuxt: Nuxt): I18nNux
4344
isBuild: nuxt.options._build,
4445
isTest: nuxt.options.test,
4546
// pages is initially undefined - has correct value when writing i18n.options template
46-
get pages() {
47-
// @ts-expect-error
48-
return nuxt.options.pages === true || (nuxt.options.pages && nuxt.options.pages?.enabled === true)
47+
get hasPages() {
48+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
49+
return nuxt.options.pages.toString()
4950
},
5051
normalizedLocales: undefined!,
5152
localeCodes: undefined!,

src/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export const normalizedLocales = ${genArrayFromRaw(opts.normalizedLocales.map(x
148148
export const NUXT_I18N_MODULE_ID = ${genString(NUXT_I18N_MODULE_ID)}
149149
export const parallelPlugin = ${ctx.options.parallelPlugin}
150150
export const isSSG = ${ctx.isSSG}
151-
export const hasPages = ${ctx.pages}
151+
export const hasPages = ${ctx.hasPages}
152152
153153
export const DEFAULT_COOKIE_KEY = ${genString(DEFAULT_COOKIE_KEY)}
154154
export const DEFAULT_DYNAMIC_PARAMS_KEY = ${genString(DEFAULT_DYNAMIC_PARAMS_KEY)}

0 commit comments

Comments
 (0)