-
Notifications
You must be signed in to change notification settings - Fork 25.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Anchor links in TOC don't change URL hash #1302
Comments
Ah, found it, at around line 3944: var n = function(e) {
return e.replace(/(:|\.|\/)/g, "\\$1")
}, If you remove the regex return, the hashes are displayed in the URL. |
If I had to guess that regex is part of the Smooth Scroll jQuery plugin. There's probably a reason for it and appears there are ways to enable the hashes so they appear in history and are focusable. |
Thanks. I put the regex back in and included @kswedberg's script and it works like a spell. |
I'm attempting to use this theme as a remote theme and thus not sure how to address this issue in that context. Any guidance? |
@vortexing You'll need to override the theme's It would probably be a smart idea to copy the entire Consult the JavaScript docs for more info on that process. https://mmistakes.github.io/minimal-mistakes/docs/javascript/ |
@mmistakes Is there a particular reason that |
@edemaine Not sure I follow. jQuery Smooth Scroll is included in the theme. Its an out of the box install, which doesn't enable the hashes for whatever reason. You can check out #1767 which tried to address that, but it had its limitations and breaks other things which is why it hasn't been merged. |
Not sure what other things the solution at #1767 breaks, but I'd be happy to take a look at something and/or change the smooth-scroll plugin if a fix is needed there |
@kswedberg See #1786 for the outstanding issues. If you have a fix feel free to submit a PR and I’ll review. |
bundle update
.bundle exec jekyll build
.Environment informations
Expected behavior
When I click an anchor link in the TOC generated with
{% include toc %}
, the active URL will change tosite/page/#anchor
.This, so that when the page is reloaded, the content from the anchor is in focus.
Steps to reproduce the behavior
site/page/#anchor
.site/page/
(i.e., https://mmistakes.github.io/minimal-mistakes/docs/layouts/), notsite/page/#anchor
.I assume that this is defined somewhere in the JavaScript, but as I'm not sure which technique is used I see myself unable to find the part where the location hash is removed. Also I'm not sure whether this is part of the theme or happens somewhere else?
The text was updated successfully, but these errors were encountered: