rust-yew-realworld-example-app icon indicating copy to clipboard operation
rust-yew-realworld-example-app copied to clipboard

GitHub Pages specific way of handling dynamic routes

Open dxps opened this issue 2 years ago • 2 comments

Describe the bug This is not an app specific issue, but it's just how GitHub Pages handles the URLs. Of course, you may argue that this is not app specific, but it seems easy to solve it.

To Reproduce Steps to reproduce the behavior:

  1. Go to Home
  2. Click on Gerome that is the author of the articles.
  3. This is working as it's handled by the SPA that runs in the browser (and the browser is informed not to do a full reload).
  4. If you access Gerome link directly (as you may do by hitting F5), then you get the classic 404 page of GitHub Pages.

Expected behavior Of course, expected to get a consistent behavior and see that page again.

Solution There seems to be a pretty standard way of handling this through examples such as this one.

Should I test it and send a PR or you'll do it?


Last but not least, thank you so much for sharing this. :pray: I'm starting to evaluate yew and I saw your comment in one of those production ready issues. That's how I got here.

dxps avatar Jun 01 '22 17:06 dxps

Basically this will not be an issue in the next release of yew, we can use HashRouter of yew, see this demo of yew-hooks repo: https://jetli.github.io/yew-hooks/#/use_async, notice the url of this page. checkout HashRouter usage here: https://github.com/jetli/yew-hooks/blob/11387ce9a9c8ab27e07b98315309de8c3a55dd7a/examples/yew-app/src/app.rs#L11

for current 0.19 version of yew, I'll investigate the hack of gh pages.

jetli avatar Jun 02 '22 01:06 jetli

Correct! While the URLs are not that pretty, hash based routing makes such issue disappear.

dxps avatar Jun 02 '22 17:06 dxps

Upgraded to yew 0.20.0 and use HashRouter

jetli avatar Nov 26 '22 14:11 jetli