hook: Add generate:page hook

This commit is contained in:
Sébastien Chopin 2017-10-30 23:14:21 +01:00
parent 2e8271f658
commit fe0ad908b7

View File

@ -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
} }