mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 06:01:34 +00:00
parent
631be3a1dd
commit
8e2d9764e2
@ -276,7 +276,7 @@ export default class Generator {
|
|||||||
// If crawler activated and called from generateRoutes()
|
// If crawler activated and called from generateRoutes()
|
||||||
if (this.options.generate.crawler && this.options.render.ssr) {
|
if (this.options.generate.crawler && this.options.render.ssr) {
|
||||||
parse(html).querySelectorAll('a').map((el) => {
|
parse(html).querySelectorAll('a').map((el) => {
|
||||||
const href = (el.getAttribute('href') || '').split('?')[0].split('#')[0].trim()
|
const href = (el.getAttribute('href') || '').replace(/\/+$/, '').split('?')[0].split('#')[0].trim()
|
||||||
|
|
||||||
if (href.startsWith('/') && !path.extname(href) && this.shouldGenerateRoute(href) && !this.generatedRoutes.has(href)) {
|
if (href.startsWith('/') && !path.extname(href) && this.shouldGenerateRoute(href) && !this.generatedRoutes.has(href)) {
|
||||||
this.generatedRoutes.add(href) // add the route to the tracked list
|
this.generatedRoutes.add(href) // add the route to the tracked list
|
||||||
|
@ -303,7 +303,7 @@ export default {
|
|||||||
this._payloadFetchIndex = 0
|
this._payloadFetchIndex = 0
|
||||||
},
|
},
|
||||||
async fetchPayload(route) {
|
async fetchPayload(route) {
|
||||||
route = (route.replace(/\/$/, '') || '/').split('?')[0]
|
route = (route.replace(/\/+$/, '') || '/').split('?')[0]
|
||||||
try {
|
try {
|
||||||
const src = urlJoin(window.__NUXT_STATIC__, route, 'payload.js')
|
const src = urlJoin(window.__NUXT_STATIC__, route, 'payload.js')
|
||||||
const payload = await window.__NUXT_IMPORT__(route, src)
|
const payload = await window.__NUXT_IMPORT__(route, src)
|
||||||
|
@ -185,7 +185,8 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
// Page level payload.js (async loaded for CSR)
|
// Page level payload.js (async loaded for CSR)
|
||||||
const payloadPath = urlJoin(url, 'payload.js')
|
const payloadPath = urlJoin(url, 'payload.js')
|
||||||
const payloadUrl = urlJoin(staticAssetsBase, payloadPath)
|
const payloadUrl = urlJoin(staticAssetsBase, payloadPath)
|
||||||
const payloadScript = `__NUXT_JSONP__("${url}", ${devalue({ data, fetch })});`
|
const routePath = (url.replace(/\/+$/, '') || '/').split('?')[0] // remove trailing slah and query params
|
||||||
|
const payloadScript = `__NUXT_JSONP__("${routePath}", ${devalue({ data, fetch })});`
|
||||||
staticAssets.push({ path: payloadPath, src: payloadScript })
|
staticAssets.push({ path: payloadPath, src: payloadScript })
|
||||||
preloadScripts.push(payloadUrl)
|
preloadScripts.push(payloadUrl)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user