diff --git a/lib/app/utils.js b/lib/app/utils.js index db83060cb0..ddaebb244f 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -61,7 +61,7 @@ export function getContext (context, app) { app: app, <%= (store ? 'store: context.store,' : '') %> route: (context.to ? context.to : context.route), - routePayload : context.routePayload, + generatePayload : context.generatePayload, error: context.error, base: '<%= router.base %>', env: <%= JSON.stringify(env) %> diff --git a/lib/generate.js b/lib/generate.js index 99aa717aee..aab432a869 100644 --- a/lib/generate.js +++ b/lib/generate.js @@ -81,11 +81,13 @@ export default async function () { } function decorateWithPayloads (routes) { let routeMap = _(routes).map((route) => { - return [route, {route, routePayload: {}}] + return [route, {route, payload: {}}] }).fromPairs().value() - generateRoutes.forEach(({route, routePayload}) => { + generateRoutes.forEach((route) => { + // route argument is either a string or like {route : "/my_route/1"} + route = _.isString(route) ? route : route.route if (!routeMap[route]) { - routeMap[route] = {route, routePayload} + routeMap[route] = {route, payload: route.payload} } }) return _.values(routeMap) @@ -97,11 +99,11 @@ export default async function () { while (routes.length) { let n = 0 - await Promise.all(routes.splice(0, 500).map(async ({route, routePayload}) => { + await Promise.all(routes.splice(0, 500).map(async ({route, payload}) => { await waitFor(n++ * this.options.generate.interval) let html try { - const res = await this.renderRoute(route, { _generate: true, routePayload }) + const res = await this.renderRoute(route, { _generate: true, generatePayload: payload }) html = res.html if (res.error) { errors.push({ type: 'handled', route, error: res.error }) diff --git a/test/fixtures/basic/nuxt.config.js b/test/fixtures/basic/nuxt.config.js index 1ba6f25737..d6ba223b68 100644 --- a/test/fixtures/basic/nuxt.config.js +++ b/test/fixtures/basic/nuxt.config.js @@ -1,9 +1,9 @@ module.exports = { generate: { routes: [ - {route: '/users/1'}, - {route: '/users/2'}, - {route: '/users/3'} + '/users/1', + '/users/2', + '/users/3' ], interval: 200 }