[RFC] Route navigation inferencing #3378
Janpot
announced in
Early feedback
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Which problem do we want to solve?
How will we solve it?
Routing
From the file system we can deduce the following information:
What we can’t deduce
To augment the default navigation structure add a
meta.tsx
to the route folder which exports this information:⇒ title for a route can be overriden with the
title
prop⇒
Icon
component can be provided⇒
children
reorders the child routes of this segment⇒ Not solved by this RFC. We will create a separate RFC if sufficient interest
⇒ Use the
hidden
prop. To hide a group of routes, add a Route group in next.js and sethidden
for this route group.Navigation Generation
We will provide
navigation.ts
file, which can then be either directly referenced by the user, or aliased in tsconfig paths. The CLI will also have a watch mode so it can be run in parallel with the project dev mode.@toolpad/core/navigation
. It combines a loader with an alias to make this happen. I’ll also provide types for this module.Generated content
The
children
propertyTo keep routes self-contained, the “children” property is only designated for ordering the routes. Options about children need to go in their own
meta.ts
. This ensures that route folders are maximally portable. One needs to be able to drag a route folder around with its configuration contained in it.Subheaders
To achieve subheaders in a navigation section, we will leverage Route groups in Next.js
Generates the following navigation section:
Use a
app/myRoute/(section1)/meta.ts
to change the title of the subheader.We will also allow to add
{ kind: 'header', title: 'Section 2' }
entries in thechildren
array of ameta.ts
so that environments that don’t support route groups can also have subheaders.Beta Was this translation helpful? Give feedback.
All reactions