Skip to content

Commit e3fbaa3

Browse files
committed
fix: replace _generate property usage
1 parent 54460af commit e3fbaa3

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

specs/utils/nuxt.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,20 @@ export async function loadFixture(testContext: VitestContext) {
6161
const buildDir = resolve(ctx.options.rootDir, '.nuxt', testKey)
6262
const outputDir = resolve(ctx.options.rootDir, '.output', testKey)
6363

64-
ctx.options.nuxtConfig = defu(ctx.options.nuxtConfig, {
65-
buildDir,
66-
// NOTE: the following code is added for prerender
67-
_generate: ctx.options.prerender,
68-
nitro: {
69-
...(ctx.options.prerender ? { static: true } : {}),
70-
output: {
71-
dir: outputDir,
72-
...(ctx.options.prerender ? { publicDir: resolve(outputDir, 'public') } : {})
64+
ctx.options.nuxtConfig = defu(
65+
ctx.options.nuxtConfig,
66+
{
67+
buildDir,
68+
// NOTE: the following code is added for prerender
69+
_generate: ctx.options.prerender,
70+
nitro: {
71+
output: {
72+
dir: outputDir
73+
}
7374
}
74-
}
75-
})
75+
},
76+
ctx.options.prerender ? { nitro: { static: true, output: { publicDir: resolve(outputDir, 'public') } } } : {}
77+
)
7678
}
7779

7880
ctx.nuxt = await kit.loadNuxt({

src/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function createContext(userOptions: NuxtI18nOptions, nuxt: Nuxt): I18nNux
4040
isDev: nuxt.options.dev,
4141
isSSR: nuxt.options.ssr,
4242
isPrepare: nuxt.options._prepare,
43-
isSSG: nuxt.options._generate,
43+
isSSG: !!nuxt.options.nitro.static,
4444
isBuild: nuxt.options._build,
4545
isTest: nuxt.options.test,
4646
// pages is initially undefined - has correct value when writing i18n.options template

src/module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default defineNuxtModule<NuxtI18nOptions>({
2929
configKey: 'i18n',
3030
compatibility: {
3131
nuxt: '>=3.0.0-rc.11',
32+
// @ts-ignore property removed in Nuxt 4
3233
bridge: false
3334
}
3435
},

src/pages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export async function setupPages({ localeCodes, options, isSSR }: I18nNuxtContex
8585

8686
// keep root when using prefixed routing without prerendering
8787
const indexPage = pages.find(x => x.path === '/')
88-
if (!nuxt.options._generate && options.strategy === 'prefix' && indexPage != null) {
88+
if (!nuxt.options.nitro.static && options.strategy === 'prefix' && indexPage != null) {
8989
localizedPages.unshift(indexPage)
9090
}
9191

0 commit comments

Comments
 (0)