-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
So I was originally expecting that @rules_prerender wouldn't really need a routing solution because it would be generic enough to support any kind of site routing. The export default entry broad is powerful enough to mostly do whatever users could want to do. However, while working on the docs site, I've changed my mind for a couple reasons.
- If a page attempts to render a navigation UI which lists all the pages, then you need to know all page URLs up front before you can render a single page. This logic gets almost circular and it can be tricky to manage.
- It is very useful for a rendered page to know where it lives in the router hierarchy and requires a lot of duplicated information if it is not tightly integrated into the route configuration.
I'm working on a proof-of-concept directly in the docs site, but I think upstreaming a more comprehensive implementation would be very useful. Currently this looks something like:
import { bootstrap } from 'rules_prerender';
export default bootstrap([
{
label: 'Home',
path: '/',
render: (currentRoute, routes) => renderToHtml(<div>Hello, World!</div>),
},
{
label: 'Tutorials',
path: '/tutorials',
// No render function, no page is created.
children: [
{
label: 'Getting Started',
path: 'getting-started',
render: (currentRoute, routes) => renderToHtml(<MyNav currentRoute={currentRoute} routes={routes} />),
},
],
},
]);The exact shape of this is TBD, but some requirements to consider based on this use case:
- A means of hiding routes from the navigation (privacy, not found).
- A means of generating parameterized routes like
/products/:id. - Application-specific data attached to individual routes in a type-safe manner.
- Two-way pointers to navigate the route tree from the current route.
- Route composition between different targets.
- Some means of discovering routes automatically? Perhaps through file-based mechanisms?
Metadata
Metadata
Assignees
Labels
No labels