Separate question: can anyone suggest how to generate a sitemap for a RAD project?
Thanks, that makes perfect sense. Just construct the map from the component tree that you can pull from the root.
well, the AST of the query of the root component, yes
which exposes the stateful component tree
But it won't produce every possible route, right? You'll need to incorporate some data you produce separately in order to get all the routes? For example, if you have some search functionality that pulls ids from a backend DB that don't exist in some report component, you'll need to pull those ids separately and add them to the tree you construct from the AST.
well certainly if there are dynamic elements to your routes that you want in your site map then yes you’re going to have to add those separately
but for the most part you don’t include every possible route in a site map…like “The form to edit employe 45722” is silly 😄
Indeed 🙂 yep, okay, I think I get the big picture for how this would work in theory.
Hmm, just relating it to my previous question about multi-part URL paths (e.g. combining two props in the URL like thing/<id>/<sub-id>), is this approach of reading the AST going to work with modifications to the html5-history or does it need to be baked into the router? Those two things are decoupled, I know, but somewhere along the way it needs to come together to produce a sitemap properly.
I’m just telling you that you can find everything via the query and looking at component options. The route segment is one of those options. You’re going to have to figure out the actual data transform.
Got it. Thanks Tony, I'll figure it out with the advice you've shared.
The whole design of dynamic routing is that the components end up in the query, so that you can compose things and have everything (including the map of possible routes) be represented by the UI composition. So, if you pull the Root query, and turn it into an AST, then you’ll have all of the components at each node (:component key). If it is a router, then the component-options will tell you the targets, etc. So, it’s just a data extraction task.
Add whatever keys you want in the route target components to help with things like labeling
E.g. if a target was given your own :route-label "Foo" as you traverse the routing tree you can pull that from the targets with component-options as well