mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-04 19:37:18 +00:00
add generate html template config
This commit is contained in:
parent
1c527c2db6
commit
75f3e9637e
@ -132,6 +132,19 @@ export default class Generator extends Tapable {
|
||||
return _.values(routeMap)
|
||||
}
|
||||
|
||||
buildHtmlFilePath (route) {
|
||||
const { html = {} } = this.options.generate
|
||||
let {
|
||||
useRouteName = false,
|
||||
fileName = 'index',
|
||||
extension = 'html'
|
||||
} = html
|
||||
extension = extension ? `.${extension}` : ''
|
||||
const name = useRouteName ? (route === '/' ? 'index' : '') : fileName
|
||||
const path = useRouteName ? `${route}${name}${extension}` : join(route, sep, `${name}${extension}`)// /about -> /about/index.html
|
||||
return (route === '/404') ? `/404${extension}` : path // /404 -> /404.html
|
||||
}
|
||||
|
||||
async generateRoute ({route, payload = {}, errors = []}) {
|
||||
let html
|
||||
|
||||
@ -154,9 +167,7 @@ export default class Generator extends Tapable {
|
||||
errors.push({ type: 'unhandled', route, error: minifyErr })
|
||||
}
|
||||
}
|
||||
|
||||
let path = join(route, sep, 'index.html') // /about -> /about/index.html
|
||||
path = (path === '/404/index.html') ? '/404.html' : path // /404 -> /404.html
|
||||
let path = this.buildHtmlFilePath(route)
|
||||
debug('Generate file: ' + path)
|
||||
path = join(this.distPath, path)
|
||||
|
||||
|
@ -149,6 +149,11 @@ Options.defaults = {
|
||||
sortClassName: true,
|
||||
trimCustomFragments: true,
|
||||
useShortDoctype: true
|
||||
},
|
||||
html: {
|
||||
useRouteName: false, // if set ture, will use the last route path as html file name, but replace route `/` with `/index`.
|
||||
fileName: 'index', // the html template file name, default 'index'.
|
||||
extension: 'html' // the html template extension type, default `html`. also can be set 'php' or jsp' or others.
|
||||
}
|
||||
},
|
||||
env: {},
|
||||
|
Loading…
Reference in New Issue
Block a user