mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 17:37:14 +00:00
renamed routePayload to payload and generatePayload in the context object. added backwards compatability with string-only routes.
This commit is contained in:
parent
64e7cab8fa
commit
b2d5186e39
@ -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) %>
|
||||
|
@ -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 })
|
||||
|
6
test/fixtures/basic/nuxt.config.js
vendored
6
test/fixtures/basic/nuxt.config.js
vendored
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user