leptos
leptos copied to clipboard
Support hashstyle routing
Is your feature request related to a problem? Please describe.
atm, laptos_router works only with the url path. E.g. when http://localhost/app/ serves
view! {
<Router>
<a href="home">Home</a>
<Routes>
<Route path="home" view=|| { view! { Home } }/>
</Routes>
</Router>
}
a click on "Home" will go to http://localhost/app/home.
This creates problems with passive hosting (e.g. as gitlab/github pages) because the url does not exist and you will get an 404 error when trying to open it directly.
You have to modify server configuration to make it work (RewriteEngine on). Even in this case, it complicates accessing relative resources because document.baseURI has changed and you will have to hardcode the application uri. It pollutes also the namespace and hides invalid URLs.
Describe the solution you'd like
It would be nice when routing is implemented as html anchors. E.g. the example above would go to http://localhost/app/#home
Implementing it manually as
view! {
<Router>
<a href="#home">Home</a>
<Routes>
<Route path="#home" view=|| { view! { Home } }/>
</Routes>
</Router>
}
does not work (laptos-router 0.5.4).
Additional context
see e.g. https://router.vuejs.org/guide/essentials/history-mode.html
Sounds good! Would you like to work on a PR?
I can work on this.
Hello ! Any update on this topic ? It would be helpful when the site is hosted on GH Pages for example! Thanks !