Skip to content

fix(router-generator): Pathless Layout Route Renders Empty HTML #4003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
13 changes: 12 additions & 1 deletion packages/router-generator/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,21 @@ export async function generator(config: Config, root: string) {
} else {
routeTree.push(node)
}
if (
node._fsRouteType === 'layout' &&
node.isVirtual &&
node.isVirtualParentRoute
) {
node.isNonPath = node.children?.every((d) => d.isNonPath)
}

routeNodes.push(node)
}

for (const node of onlyGeneratorRouteNodes) {
await handleNode(node)
}

checkRouteFullPathUniqueness(
preRouteNodes.filter(
(d) =>
Expand Down Expand Up @@ -835,7 +843,10 @@ function removeGroups(s: string) {
*/
function determineNodePath(node: RouteNode) {
return (node.path = node.parent
? node.routePath?.replace(node.parent.routePath ?? '', '') || '/'
? node.routePath?.replace(
node.parent.isNonPath ? '' : (node.parent.routePath ?? ''),
'',
) || '/'
: node.routePath)
}

Expand Down
Loading