T
TanStack2y ago
extended-salmon

Splat routes with final fixed route segments

I have a use case that right now it's not supported by TSR. I work with a CMS that uses a concept that is called "object traversal" to retrieve the objects stored in the CMS database. The objects are stored in an objects/documents DB that is able to store them in a hierarchically way (as a file system, with parent/child structure). So they map the way it's stored directly with the natural organization of a website: /folder/nested-folder/page in the DB, the folder object is the parent of nested-folder and this one, will be parent of page. so when the user calls that URL, it traverses the tree until it gets to the page content, then that content is rendered. We can match this via "splat" routes, all fine. Then, the tricky part. The traversal concept also accepts the idea of "views" or actions applied to the content objects. Then the edit view becomes: /folder/nested-folder/page/edit I noticed this can't be achieved, nor in TSR, nor in any other modern router. We are using RR5, which supported this back then, but I noticed that RR6 does not support it either. Is that something that it's sensible to add as a feature? is it difficult to achieve? Thanks for in advance!
11 Replies
exotic-emerald
exotic-emerald2y ago
can you please create a github issue so this feature request does not get lost here?
extended-salmon
extended-salmonOP2y ago
@Manuel Schiller sure
extended-salmon
extended-salmonOP2y ago
@Manuel Schiller I created a feature request: https://github.com/TanStack/router/discussions/1171
GitHub
Support for splat/catch all routes with final fixed route segments ...
I have a use case that right now it's not supported by TSR. I'd say it's not an issue, more than a lack of support/feature request. I work with a CMS (https://plone.org) that uses a con...
extended-salmon
extended-salmonOP2y ago
the frontier between an issue and a feature request is thin sometimes
exotic-emerald
exotic-emerald2y ago
true you are also welcome to submit a PR that implements this, even if it is just to get this started a bit faster
extended-salmon
extended-salmonOP2y ago
I'd love to, that's why I asked if it would be hard to achieve (because it's not supported in any modern router) if it's doable, having some directions would be great too, just to get started
exotic-emerald
exotic-emerald2y ago
I can imagine that there might be situations where route matching is ambiguous but we will only know when someone tries it out
extended-salmon
extended-salmonOP2y ago
yeah, it forces you to have "reserved words", so your content can't be named "edit"
exotic-emerald
exotic-emerald2y ago
maybe @Tanner Linsley has tried this before, any comments on this?
extended-salmon
extended-salmonOP2y ago
but the traversal concept is a powerful one, in the Plone/Zope community we've been using it since 20 years ago, in the backend server side Python implementation of the CMS and we are also using it in Volto our React based UI for Plone (using RR5, right now). We need to run from our current (legacy) architecture which is using Razzle and other legacy tools, and we are evaluating options.
rare-sapphire
rare-sapphire2y ago
So in terms of TSR, this would be possible, and would mean the segment matching logic would need to be updated to allow for some kind of look behind on a splat route. Eg, first match the splat, then if the splat has children, use the suffix of the splat to continue matching This would effectively turn the splat functionality into a more generic multi segment matching utility And that’s how I would implement it It would still be a catch all, but child routes would be able to optionally pick up on inner or suffix segments.

Did you find this page helpful?