mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 07:40:33 +00:00
Fix duplicate routes and hidden files
This commit is contained in:
parent
8cbbaeaf83
commit
b8436b067f
@ -1,7 +1,7 @@
|
||||
module.exports = {
|
||||
router: {
|
||||
routes: [
|
||||
{ name: 'user', path: '/users/:id', component: '~pages/_user' }
|
||||
{ name: 'user', path: '/users/:id', component: 'pages/_user' }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -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 %>')
|
||||
<% }) %>
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user