sort keys

This commit is contained in:
Alexandre Chopin 2016-12-23 15:43:01 +01:00
parent 7148502e37
commit 2fff5e7a4f
1 changed files with 6 additions and 5 deletions

View File

@ -211,11 +211,12 @@ function createRoutes (files, srcDir) {
})
route._name = '_' + hash(route.component)
// Order Routes path
if (_.last(keys)[0] === '_') {
parent.push(route)
} else {
parent.unshift(route)
}
parent.push(route)
parent.sort((a, b) => {
var isA = (a.path[0] === ':' || a.path[1] === ':') ? 1 : 0
var isB = (b.path[0] === ':' || b.path[1] === ':') ? 1 : 0
return (isA - isB === 0) ? a.path.length - b.path.length : isA - isB
})
})
return cleanChildrenRoutes(routes)
}