Skip to content

Commit def5590

Browse files
committed
Combine routes and namespaces
1 parent 7d33ff2 commit def5590

2 files changed

Lines changed: 4 additions & 21 deletions

File tree

codegen/layouts/route.hbs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
class {{className}} {
44
{{> route-class-methods }}
55

6-
{{#each namespaces}}
7-
{{> route-class-subroute }}
8-
9-
{{/each}}
10-
116
{{#each subroutes}}
127
{{> route-class-subroute }}
138

codegen/lib/connect.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,13 @@ const setRouteLayoutContext = (
111111

112112
file.endpoints = [] // TODO
113113

114-
file.namespaces = blueprint.namespaces
114+
file.subroutes = [...blueprint.routes, ...blueprint.namespaces]
115+
.sort((n1, n2) => n1.name.localeCompare(n2.name))
115116
.filter(({ parentPath }) => parentPath === (node?.path ?? null))
116-
.map((r) => getSubrouteLayoutContextFromNamespace(r))
117-
118-
file.subroutes = blueprint.routes
119-
.filter(({ parentPath }) => parentPath === (node?.path ?? null))
120-
.map((r) => getSubrouteLayoutContextFromRoute(r))
117+
.map((r) => getSubrouteLayoutContext(r))
121118
}
122119

123-
const getSubrouteLayoutContextFromRoute = (
120+
const getSubrouteLayoutContext = (
124121
route: Pick<Route, 'path' | 'name'>,
125122
): SubrouteLayoutContext => {
126123
return {
@@ -129,12 +126,3 @@ const getSubrouteLayoutContextFromRoute = (
129126
className: getClassName(route.path),
130127
}
131128
}
132-
133-
const getSubrouteLayoutContextFromNamespace = (
134-
namespace: Namespace,
135-
): SubrouteLayoutContext => {
136-
return {
137-
...getSubrouteLayoutContextFromRoute(namespace),
138-
fileName: `${kebabCase(namespace.name)}/index.js`,
139-
}
140-
}

0 commit comments

Comments
 (0)