mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 16:12:12 +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,
|
app: app,
|
||||||
<%= (store ? 'store: context.store,' : '') %>
|
<%= (store ? 'store: context.store,' : '') %>
|
||||||
route: (context.to ? context.to : context.route),
|
route: (context.to ? context.to : context.route),
|
||||||
routePayload : context.routePayload,
|
generatePayload : context.generatePayload,
|
||||||
error: context.error,
|
error: context.error,
|
||||||
base: '<%= router.base %>',
|
base: '<%= router.base %>',
|
||||||
env: <%= JSON.stringify(env) %>
|
env: <%= JSON.stringify(env) %>
|
||||||
|
@ -81,11 +81,13 @@ export default async function () {
|
|||||||
}
|
}
|
||||||
function decorateWithPayloads (routes) {
|
function decorateWithPayloads (routes) {
|
||||||
let routeMap = _(routes).map((route) => {
|
let routeMap = _(routes).map((route) => {
|
||||||
return [route, {route, routePayload: {}}]
|
return [route, {route, payload: {}}]
|
||||||
}).fromPairs().value()
|
}).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]) {
|
if (!routeMap[route]) {
|
||||||
routeMap[route] = {route, routePayload}
|
routeMap[route] = {route, payload: route.payload}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return _.values(routeMap)
|
return _.values(routeMap)
|
||||||
@ -97,11 +99,11 @@ export default async function () {
|
|||||||
|
|
||||||
while (routes.length) {
|
while (routes.length) {
|
||||||
let n = 0
|
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)
|
await waitFor(n++ * this.options.generate.interval)
|
||||||
let html
|
let html
|
||||||
try {
|
try {
|
||||||
const res = await this.renderRoute(route, { _generate: true, routePayload })
|
const res = await this.renderRoute(route, { _generate: true, generatePayload: payload })
|
||||||
html = res.html
|
html = res.html
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
errors.push({ type: 'handled', route, error: 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 = {
|
module.exports = {
|
||||||
generate: {
|
generate: {
|
||||||
routes: [
|
routes: [
|
||||||
{route: '/users/1'},
|
'/users/1',
|
||||||
{route: '/users/2'},
|
'/users/2',
|
||||||
{route: '/users/3'}
|
'/users/3'
|
||||||
],
|
],
|
||||||
interval: 200
|
interval: 200
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user