create-routes
v1.0.2
Published
generate routes for nuxt pages.
Downloads
14
Readme
create-routes
generate routes for nuxt pages.
Installation
npm install create-routes --save
Examples
This file tree:
pages/
--| _slug/
-----| comments.vue
-----| index.vue
--| user/
-----| index.vue
-----| one.vue
--| users/
-----| _id.vue
-----| index.vue
--| index.vue
will automatically generate:
[
{
"path": "/:slug",
"name": "slug",
"component": "test/pages/_slug/index.vue",
"children": [
{
"path": "/:slug/comments",
"name": "comments",
"component": "test/pages/_slug/comments.vue"
}
]
},
{
"path": "/",
"name": "main",
"component": "test/pages/index.vue"
},
{
"path": "/user",
"name": "user",
"component": "test/pages/user/index.vue",
"children": [
{
"path": "/user/one",
"name": "one",
"component": "test/pages/user/one.vue"
}
]
},
{
"path": "/users",
"name": "users",
"component": "test/pages/users/index.vue",
"children": [
{
"path": "/users/:id",
"name": "id",
"component": "test/pages/users/_id.vue"
}
]
}
]
Usage
import createRoutes from 'create-routes'
const routes = createRoutes({
rootDir: __dirname,
pagesDir: 'test/pages'
})