Skip to content

Commit b505c7f

Browse files
committed
Always generate index files
1 parent 4da27e4 commit b505c7f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

codegen/lib/connect.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,17 @@ export const connect = (
4141
setRouteLayoutContext(file, namespace, blueprint)
4242

4343
const parentPath = namespace.parentPath ?? ''
44-
45-
routeIndexes[parentPath] ??= new Set()
4644
routeIndexes[parentPath]?.add(`${kebabCase(namespace.name)}.js`)
4745
routeIndexes[parentPath]?.add(`${kebabCase(namespace.name)}/index.js`)
46+
47+
const pathParts = parentPath.split('/')
48+
while (pathParts.length > 1) {
49+
const name = pathParts.pop()
50+
if (name == null) throw new Error('Unexpected null')
51+
const path = toFilePath(`/${pathParts.join('/')}`)
52+
routeIndexes[path] ??= new Set()
53+
routeIndexes[path]?.add(`${kebabCase(name)}/index.js`)
54+
}
4855
}
4956

5057
for (const route of routes) {

0 commit comments

Comments
 (0)