Skip to content
This repository was archived by the owner on Jul 10, 2019. It is now read-only.

Commit f5aada0

Browse files
committed
refactor(nuxt.config.ts): add type route interface
1 parent 10605f8 commit f5aada0

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

nuxt.config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,10 @@ module.exports = {
125125
middleware: 'check-auth',
126126

127127
extendRoutes(routes: any, resolve: any) {
128+
// https://ja.nuxtjs.org/api/configuration-router/#extendroutes
128129
if (routers && routers.length > 0) {
129130
for (let i = 0, len = routers.length; i < len; i++) {
130-
routers[i](routes, resolve)
131+
routes.push(routers[i](resolve))
131132
}
132133
}
133134
}

src/interface/INuxtRoute.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Nuxt の route インターフェイス
3+
*/
4+
export default interface INuxtRoute {
5+
name: string
6+
path: string
7+
component: string
8+
}

src/routers/custom-path.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
export default function(routes: any, resolve: any): void {
2-
// https://ja.nuxtjs.org/api/configuration-router/#extendroutes
3-
routes.push({
1+
import INuxtRoute from '../interface/INuxtRoute'
2+
3+
export default function(
4+
resolve: (dirname: string, routeDir: string) => string
5+
): INuxtRoute {
6+
return {
47
name: 'custom-path',
58
path: '/example/(c|d)-:a/(e|f)-:b/*',
69
component: resolve(__dirname, '../../src/routed-pages/custom-path.vue')
7-
})
10+
}
811
}

src/routers/include.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
export default function(routes: any, resolve: any): void {
2-
routes.push({
1+
import INuxtRoute from '../interface/INuxtRoute'
2+
3+
export default function(
4+
resolve: (dirname: string, routeDir: string) => string
5+
): INuxtRoute {
6+
return {
37
name: 'include',
48
path: '/include',
59
component: resolve(__dirname, '../../src/include/include.vue')
6-
})
10+
}
711
}

0 commit comments

Comments
 (0)