mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-07 09:22:27 +00:00
hook: Add generate:page hook
This commit is contained in:
parent
2e8271f658
commit
fe0ad908b7
@ -182,12 +182,17 @@ export default class Generator {
|
|||||||
|
|
||||||
let path = join(route, sep, 'index.html') // /about -> /about/index.html
|
let path = join(route, sep, 'index.html') // /about -> /about/index.html
|
||||||
path = (path === '/404/index.html') ? '/404.html' : path // /404 -> /404.html
|
path = (path === '/404/index.html') ? '/404.html' : path // /404 -> /404.html
|
||||||
debug('Generate file: ' + path)
|
|
||||||
path = join(this.distPath, path)
|
// Call hook to let user update the path & html
|
||||||
|
const page = { route, path, html }
|
||||||
|
await this.nuxt.callHook('generate:page', page)
|
||||||
|
|
||||||
|
debug('Generate file: ' + page.path)
|
||||||
|
page.path = join(this.distPath, page.path)
|
||||||
|
|
||||||
// Make sure the sub folders are created
|
// Make sure the sub folders are created
|
||||||
await mkdirp(dirname(path))
|
await mkdirp(dirname(page.path))
|
||||||
await writeFile(path, html, 'utf8')
|
await writeFile(page.path, page.html, 'utf8')
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user