Fix duplicate routes and hidden files

This commit is contained in:
Alexandre Chopin 2016-11-20 12:23:48 +01:00
parent 8cbbaeaf83
commit b8436b067f
4 changed files with 7 additions and 5 deletions

View File

@ -1,7 +1,7 @@
module.exports = {
router: {
routes: [
{ name: 'user', path: '/users/:id', component: '~pages/_user' }
{ name: 'user', path: '/users/:id', component: 'pages/_user' }
]
}
}

View File

@ -5,7 +5,7 @@ import Router from 'vue-router'
Vue.use(Router)
<% router.routes.forEach(function (route) { %>
<% uniqBy(router.routes, '_name').forEach((route) => { %>
const <%= route._name %> = process.BROWSER ? () => System.import('<%= route._component %>') : require('<%= route._component %>')
<% }) %>

View File

@ -10,7 +10,8 @@ const hash = require('hash-sum')
const pify = require('pify')
const webpack = require('webpack')
const { createBundleRenderer } = require('vue-server-renderer')
const { join, resolve, sep } = require('path')
const { join, resolve, sep, posix } = require('path')
const basename = posix.basename
const remove = pify(fs.remove)
const readFile = pify(fs.readFile)
const writeFile = pify(fs.writeFile)
@ -140,7 +141,7 @@ function * generateRoutesAndFiles () {
let routes = []
files.forEach((file) => {
let path = file.replace(/^pages/, '').replace(/index\.vue$/, '/').replace(/\.vue$/, '').replace(/\/{2,}/g, '/')
if (path[1] === '_') return
if (basename(path)[0] === '_') return
routes.push({ path: path, component: r(this.dir, file) })
})
// Concat pages routes and custom routes in this.routes
@ -161,6 +162,7 @@ function * generateRoutesAndFiles () {
'components/nuxt-loading.vue'
]
let templateVars = {
uniqBy: _.uniqBy,
isDev: this.dev,
router: {
base: this.options.router.base,

View File

@ -1,6 +1,6 @@
{
"name": "nuxt",
"version": "0.5.1",
"version": "0.5.2",
"description": "A minimalistic framework for server-rendered Vue.js applications (inspired by Next.js)",
"main": "index.js",
"license": "MIT",