mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
Add _name in router template
This commit is contained in:
parent
ef4065b350
commit
be6562f244
@ -9,6 +9,7 @@ Vue.use(Router)
|
||||
function recursiveRoutes(routes, tab, components) {
|
||||
var res = ''
|
||||
routes.forEach((route, i) => {
|
||||
route._name = '_' + hash(route.component)
|
||||
components.push({ _name: route._name, component: route.component })
|
||||
res += tab + '{\n'
|
||||
res += tab + '\tpath: ' + JSON.stringify(route.path) + ',\n'
|
||||
|
@ -205,7 +205,10 @@ function * generateRoutesAndFiles () {
|
||||
return readFile(r(__dirname, 'app', file), 'utf8')
|
||||
.then((fileContent) => {
|
||||
const template = _.template(fileContent, {
|
||||
imports: { serialize }
|
||||
imports: {
|
||||
serialize,
|
||||
hash
|
||||
}
|
||||
})
|
||||
const content = template(templateVars)
|
||||
return writeFile(r(this.dir, '.nuxt', file), content, 'utf8')
|
||||
@ -218,7 +221,7 @@ function createRoutes (files, srcDir) {
|
||||
let routes = []
|
||||
files.forEach((file) => {
|
||||
let keys = file.replace(/^pages/, '').replace(/\.vue$/, '').replace(/\/{2,}/g, '/').split('/').slice(1)
|
||||
let route = { name: '', path: '', component: r(srcDir, file), _name: null }
|
||||
let route = { name: '', path: '', component: r(srcDir, file) }
|
||||
let parent = routes
|
||||
keys.forEach((key, i) => {
|
||||
route.name = route.name ? route.name + '-' + key.replace('_', '') : key.replace('_', '')
|
||||
@ -240,7 +243,6 @@ function createRoutes (files, srcDir) {
|
||||
}
|
||||
}
|
||||
})
|
||||
route._name = '_' + hash(route.component)
|
||||
// Order Routes path
|
||||
parent.push(route)
|
||||
parent.sort((a, b) => {
|
||||
|
Loading…
Reference in New Issue
Block a user