craftinginterpreters icon indicating copy to clipboard operation
craftinginterpreters copied to clipboard

[Web] Improve UX of current location

Open grouma opened this issue 3 years ago • 1 comments

The web version of the book has support for deep links through a # URL scheme, e.g. https://craftinginterpreters.com/scanning.html#the-interpreter-framework. However, the web page does not update the URL as you scroll through the book and therefore can become out of sync (see image below).

It would also be great if the sidebar nav links also changed state depending on the current location. They already support a hover styling which likely would be sufficient.

The points mentioned above are highlighted in red for clarity: Screenshot 2022-07-24 10 48 52 PM

grouma avatar Jul 25 '22 03:07 grouma

I was curious how I'd implement this support and found this JSFiddle that is likely helpful. Probably need to use window.history.pushstate as well. Probably easy to stuff here.

grouma avatar Jul 25 '22 03:07 grouma