@@ -33,11 +33,7 @@ export const connect = (
3333 )
3434
3535 for ( const namespace of namespaces ) {
36- const k = `${ rootPath } /${ namespace . path
37- . slice ( 1 )
38- . split ( '/' )
39- . map ( ( p ) => kebabCase ( p ) )
40- . join ( '/' ) } /${ kebabCase ( namespace . name ) } .ts`
36+ const k = `${ rootPath } /${ toFilePath ( namespace . path ) } .ts`
4137
4238 files [ k ] = { contents : Buffer . from ( '\n' ) }
4339 const file = files [ k ] as unknown as File
@@ -53,11 +49,7 @@ export const connect = (
5349 }
5450
5551 for ( const route of routes ) {
56- const k = `${ rootPath } /${ route . path
57- . slice ( 1 )
58- . split ( '/' )
59- . map ( ( p ) => kebabCase ( p ) )
60- . join ( '/' ) } .ts`
52+ const k = `${ rootPath } /${ toFilePath ( route . path ) } .ts`
6153
6254 files [ k ] = { contents : Buffer . from ( '\n' ) }
6355 const file = files [ k ] as unknown as File
@@ -72,18 +64,22 @@ export const connect = (
7264 for ( const [ parentPath , routes ] of Object . entries ( routeIndexes ) ) {
7365 const k =
7466 parentPath === ''
75- ? `${ rootPath } /index.js`
76- : `${ rootPath } ${ parentPath
77- . split ( '/' )
78- . map ( ( p ) => kebabCase ( p ) )
79- . join ( '/' ) } /index.js`
67+ ? `${ rootPath } /index.ts`
68+ : `${ rootPath } /${ toFilePath ( parentPath ) } /index.ts`
8069 files [ k ] = { contents : Buffer . from ( '\n' ) }
8170 const file = files [ k ] as unknown as File
8271 file . layout = 'route-index.hbs'
8372 file . routes = [ ...routes ]
8473 }
8574}
8675
76+ const toFilePath = ( path : string ) : string =>
77+ path
78+ . slice ( 1 )
79+ . split ( '/' )
80+ . map ( ( p ) => kebabCase ( p ) )
81+ . join ( '/' )
82+
8783interface RouteIndexLayoutContext {
8884 routes : string [ ]
8985}
0 commit comments