Skip to content

Commit

Permalink
fix: routePathID now obeys routeFilePrefix (#818)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yavonix authored Nov 17, 2023
1 parent 4dbd334 commit c40902b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/router-cli/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export async function generator(config: Config) {
}

const start = Date.now()
const routePathIdPrefix = config.routeFilePrefix ?? ''

let routeNodes = await getRouteNodes(config)

Expand All @@ -125,7 +126,7 @@ export async function generator(config: Config) {
(d) => d.routePath?.split('/').length,
(d) => (d.routePath?.endsWith('/') ? -1 : 1),
(d) => d.routePath,
]).filter((d) => d.routePath !== `/${rootPathId}`)
]).filter((d) => d.routePath !== `/${routePathIdPrefix + rootPathId}`)

const routeTree: RouteNode[] = []

Expand Down Expand Up @@ -211,11 +212,11 @@ export async function generator(config: Config) {
`import { route as rootRoute } from './${sanitize(
path.relative(
path.dirname(config.generatedRouteTree),
path.resolve(config.routesDirectory, rootPathId),
path.resolve(config.routesDirectory, routePathIdPrefix + rootPathId),
),
)}'`,
...multiSortBy(routeNodes, [
(d) => (d.routePath?.includes(`/${rootPathId}`) ? -1 : 1),
(d) => (d.routePath?.includes(`/${routePathIdPrefix + rootPathId}`) ? -1 : 1),
(d) => d.routePath?.split('/').length,
(d) => (d.routePath?.endsWith("index'") ? -1 : 1),
(d) => d,
Expand Down

0 comments on commit c40902b

Please sign in to comment.