bug: Broken links depending on the window history
Is there an existing issue for this?
- [x] I have searched the existing issues
Description of the bug
I have come across some strange behaviour as I make my way through the documentation. When I open the page using a direct link, some relative links seem to be broken, although they work when I visit a page within the folder first. I wanted to report this behaviour as I'm not familiar enough with this type of problem. Other sites with ./ links also have this problem.
Steps To Reproduce
- Open https://sapphirejs.dev/docs/Guide/commands/application-commands/what-are-application-commands
- Click on the link "Application Command Registry" in the last sentence of this page
- You get redirected to https://sapphirejs.dev/docs/Guide/commands/application-commands/what-are-application-commands/application-command-registry/what-is-it
Expected behavior
You get redirected to https://sapphirejs.dev/docs/Guide/commands/application-commands/application-command-registry/what-is-it
Screenshots
No response
Additional context
Steps to reproduce the same link working properly:
- Open https://sapphirejs.dev/docs/Guide/commands/application-commands/application-command-registry/acquiring-an-application-command-registry
- Click on the link "What are application commands?" in the sidebar
- You get redirected to https://sapphirejs.dev/docs/Guide/commands/application-commands/what-are-application-commands
- Click on the link "Application Command Registry" in the last sentence of this page
- You get redirected to https://sapphirejs.dev/docs/Guide/commands/application-commands/application-command-registry/what-is-it (expected behavior)
System Info
N.A.
I think I have found the bug that is causing this problem as I was trying the updated version. Visiting the site directly adds an
/at the end of the path if there isn't one already. If I interact with the sidebar the site navigates me to to the path without the/at the end. Therefore relative links get confused.
As outlined in https://github.com/sapphiredev/website/pull/294#pullrequestreview-2574109596 the pull request did fix the issue I was describing but broke it the other way around as the real issue was not the relative link being incorrect but rather the / that gets added to the path if you visit the site directly / via an external site.
To fix this issue, #294 needs to be reverted and the cause for the / needs to be identified and removed (or added to all the sidebar links and adjusted accordingly)
I tried looking into this more and for the life of me I cannot find a proper solution. Especially since the sidebar and a lot of the site are generated from markdown files.
Probably it's worth taking a look at the Docusaurus config field trailingSlash and the resources linked over there. Otherwise I'd suggest using absolute instead of relative links to mitigate this issue