rubydoc: fix sidebar navigation links on nested pages by GunniBusch · Pull Request #21589 · Homebrew/brew
Ok, this is bigger than I thought. The core error is that the nav side bar, which is an iframe, does not navigate using the correct relative path. This means that if you click on a nav item that url e.g. /Bottle/somehtml.html is relative to the current url not the base url.
Sadly, my fix made it work, but also broke all other links, since those were already relative.
We can trace this back to multiple sources, but I do not think the GitHub Pages move is the cause.
I would like to share the main sources of this error:
- There is only one class_list.html. This is technically fine, but it means we cannot use YARD templates to fix this at the nav bar source. As a result, the hrefs are always relative to the current base path, but do not point to the actual root.
- app.js does not make use of the relpath variable defined in https://github.com/lsegal/yard/blob/main/templates/default/layout/html/script_setup.erb even though relpath always correctly points to the root.
I tried to find a small fix for this issue, but I keep running into new problems. The current solution worked, but only for root-level pages. Navigating into nested pages works until you refresh, which I missed testing yesterday.
The best approach might be to integrate app.js into the codebase, make a small targeted change, and then open a PR upstream so we can restore the intended behavior and eventually remove it.
A different solution, I currently test, would be to automatically change append the href with the relpath variable, which doesn't change the app.js, but I currently figuring that out