Multiple routes point to the same LiveView, how does the live_path function explicitly get one of them?

E.g:

live "/c/:category_id", IndexLive
live "/t/:tag_id", IndexLive

Use the live_link to navigate:

<%= live_link “Hello”, 
           to: Routes.live_path(@socket, BlogWeb.IndexLive, 10001) %>

As above, only paths with a link of /c/10001 can be generated. How do I choose to generate the /t/10001 path?

Have you tried with the :as option?

live "/c/:category_id", IndexLive, as: "c_route"
live "/t/:tag_id", IndexLive, as: "t_route"
5 Likes