From c40902ba690c676b06291951e9b02c65eea28603 Mon Sep 17 00:00:00 2001 From: Yavonix <37795234+Yavonix@users.noreply.github.com> Date: Sat, 18 Nov 2023 01:21:10 +1000 Subject: [PATCH] fix: routePathID now obeys routeFilePrefix (#818) --- packages/router-cli/src/generator.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/router-cli/src/generator.ts b/packages/router-cli/src/generator.ts index 8f1675af0d..8263b26f72 100644 --- a/packages/router-cli/src/generator.ts +++ b/packages/router-cli/src/generator.ts @@ -117,6 +117,7 @@ export async function generator(config: Config) { } const start = Date.now() + const routePathIdPrefix = config.routeFilePrefix ?? '' let routeNodes = await getRouteNodes(config) @@ -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[] = [] @@ -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,