mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
generate routes flatten
This commit is contained in:
parent
b71b8b7478
commit
da9c311b54
@ -136,6 +136,9 @@ function * generateRoutesAndFiles () {
|
||||
** Generate routes based on files
|
||||
*/
|
||||
const files = yield glob('pages/**/*.vue', { cwd: this.srcDir })
|
||||
this.routes = _.uniq(_.map(files, (file) => {
|
||||
return file.replace(/^pages/, '').replace(/\.vue$/, '').replace('/index', '').replace('_', ':').replace('', '/').replace(/\/{2,}/g, '/')
|
||||
}))
|
||||
/*
|
||||
** Interpret and move template files to .nuxt/
|
||||
*/
|
||||
@ -175,7 +178,7 @@ function * generateRoutesAndFiles () {
|
||||
templateVars.loading = templateVars.loading + '.vue'
|
||||
}
|
||||
// Format routes for the lib/app/router.js template
|
||||
templateVars.router.routes = this.routes = createRoutes(files, this.srcDir)
|
||||
templateVars.router.routes = createRoutes(files, this.srcDir)
|
||||
if (fs.existsSync(join(this.srcDir, 'layouts', 'app.vue'))) {
|
||||
templateVars.appPath = r(this.srcDir, 'layouts/app.vue')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user