mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
delete option routes.router
This commit is contained in:
parent
cc15926340
commit
32a6f30118
@ -1,18 +1,18 @@
|
||||
module.exports = {
|
||||
router: {
|
||||
routes: {
|
||||
author: {
|
||||
alias: '/nuxt'
|
||||
},
|
||||
users: {
|
||||
_id: {
|
||||
regexp: ':id(\\d+)'
|
||||
// generate: [1, 2, 3, 4] // Need to be finished on generate
|
||||
}
|
||||
},
|
||||
posts: {
|
||||
alias: '/articles'
|
||||
}
|
||||
// author: {
|
||||
// alias: '/nuxt'
|
||||
// },
|
||||
// users: {
|
||||
// _id: {
|
||||
// regexp: ':id(\\d+)'
|
||||
// // generate: [1, 2, 3, 4] // Need to be finished on generate
|
||||
// }
|
||||
// },
|
||||
// posts: {
|
||||
// alias: '/articles'
|
||||
// }
|
||||
}
|
||||
},
|
||||
// generate: {
|
||||
|
@ -15,8 +15,6 @@ function recursiveRoutes(routes, tab) {
|
||||
res += tab + '\tpath: ' + JSON.stringify(route.path) + ',\n'
|
||||
res += tab + '\tcomponent: ' + route._name
|
||||
res += (route.name) ? ',\n\t' + tab + 'name: ' + JSON.stringify(route.name) : ''
|
||||
res += (route.alias) ? ',\n\t' + tab + 'alias: ' + JSON.stringify(route.alias) : ''
|
||||
res += (route.meta) ? ',\n\t' + tab + 'meta: ' + JSON.stringify(route.meta) : ''
|
||||
res += (route.children) ? ',\n\t' + tab + 'children: [\n' + recursiveRoutes(routes[i].children, tab + '\t\t') + '\n\t' + tab + ']' : ''
|
||||
res += '\n' + tab + '}' + (i + 1 === routes.length ? '' : ',\n')
|
||||
})
|
||||
|
@ -175,7 +175,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, this.options.router.routes)
|
||||
templateVars.router.routes = this.routes = createRoutes(files, this.srcDir)
|
||||
if (fs.existsSync(join(this.srcDir, 'layouts', 'app.vue'))) {
|
||||
templateVars.appPath = r(this.srcDir, 'layouts/app.vue')
|
||||
}
|
||||
@ -193,7 +193,7 @@ function * generateRoutesAndFiles () {
|
||||
yield moveTemplates
|
||||
}
|
||||
|
||||
function createRoutes (files, srcDir, options = {}) {
|
||||
function createRoutes (files, srcDir) {
|
||||
let routes = []
|
||||
files.forEach((file) => {
|
||||
let keys = file.replace(/^pages/, '').replace(/\.vue$/, '').replace(/\/{2,}/g, '/').split('/').slice(1)
|
||||
@ -212,22 +212,8 @@ function createRoutes (files, srcDir, options = {}) {
|
||||
}
|
||||
})
|
||||
route._name = '_' + hash(route.component)
|
||||
let lastkey = _.last(keys)
|
||||
const path = _.result(options, keys.join('.'))
|
||||
if (path) {
|
||||
// Update path with regexp in config
|
||||
if (path.regexp) {
|
||||
route.path = route.path.replace(lastkey.replace('_', ':'), path.regexp)
|
||||
}
|
||||
if (path.meta) {
|
||||
route.meta = path.meta
|
||||
}
|
||||
if (path.alias) {
|
||||
route.alias = path.alias
|
||||
}
|
||||
}
|
||||
// Order Routes path
|
||||
if (lastkey[0] === '_') {
|
||||
if (_.last(keys)[0] === '_') {
|
||||
parent.push(route)
|
||||
} else {
|
||||
parent.unshift(route)
|
||||
|
Loading…
Reference in New Issue
Block a user