Fork me on GitHub
#fulcro
<
2022-07-12
>
Jake Murphy16:07:49

How can I setup a route to "http://example.com", "http://example.com/"? I'd like to have a router in the root component. I'd like the landing page to be a route target. But route targets cannot be empty. (dynamic routing)

Jakub Holý (HolyJak)18:07:33

So you have two problems: (1) you want some-path/ and some-path to route to the same component and (2) you want the Root to be route target. Correct? For (1) I would leave that outside of dyn. routing and put it instead in the glue code between URLs and Fulcro routes. A kind of "normalization" of the route. For (2) I do not understand why would you want that. There is just a single root component (otherwise it would not be a root) so routing at that level does not make sense. Could you explain you use case?

Jake Murphy18:07:58

It makes sense to me to place a router in the root component. That way, a router is in full control of which page is being shown. But I also want a landing page to be shown when there is no path string (http://example.com or http://example.com/). I'm scratching my head as to how to send the user to this route since it has no path segments and you cannot declare a route-target for [] or [""].

Jake Murphy18:07:37

I've used routers in the past where I can define it like:`["" {:map of route data} ["/subroute" {:map of sub-route data}]`

Jakub Holý (HolyJak)19:07:08

Then have a single Root component that includes a router child with different Page targets.

Jakub Holý (HolyJak)19:07:38

> I'm scratching my head as to how to send the user to this route since it has no path segments As mentioned, url != route. In the glue code between the two you can make "" to a route such as "default" or whatever. I do st. similar here https://github.com/holyjak/fulcro-billing-app/blob/main/src/shared/billing_app/client.cljs#L155

Jake Murphy20:07:50

Okay, so I might be able to give the component a route-segment such ["landing"] and then change this to and from "" in whatever history updater I use. Thank you, I'm going to look into that.

1