Skip to content

Commit

Permalink
hook: Add generate:page hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed Oct 30, 2017
1 parent 2e8271f commit fe0ad90
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/builder/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,17 @@ export default class Generator {

let path = join(route, sep, 'index.html') // /about -> /about/index.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
await mkdirp(dirname(path))
await writeFile(path, html, 'utf8')
await mkdirp(dirname(page.path))
await writeFile(page.path, page.html, 'utf8')

return true
}
Expand Down

0 comments on commit fe0ad90

Please sign in to comment.