diff --git a/examples/custom-routes/nuxt.config.js b/examples/custom-routes/nuxt.config.js index eb87411f1b..38fa87ebb2 100644 --- a/examples/custom-routes/nuxt.config.js +++ b/examples/custom-routes/nuxt.config.js @@ -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: { diff --git a/lib/app/router.js b/lib/app/router.js index 0ce1e29778..7c94ceba75 100644 --- a/lib/app/router.js +++ b/lib/app/router.js @@ -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') }) diff --git a/lib/build/index.js b/lib/build/index.js index 1b1cf7a1ee..a5eee551b4 100644 --- a/lib/build/index.js +++ b/lib/build/index.js @@ -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)