-
Notifications
You must be signed in to change notification settings - Fork 18k
x/website: show anchor links for article headings #68596
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
Comments
Change https://go.dev/cl/601055 mentions this issue: |
@hyangah, thank you so much for doing this! The lack of this has bothered me for years and caused me to open up the inspector for each heading's ID to deep link to blog article sections! I am elated I no longer have to do this. |
Change https://go.dev/cl/618635 mentions this issue: |
I'm just here to echo what @matttproud said, this is amazing! I just created the anchor link https://go.dev/doc/comment#doclinks manually because I've been doing this for years and it didn't even occur to me that this got fixed 🙇 |
@hyangah just one request - when I hover over "Doc Links", nothing happens - which is why I didn't even realise this got fixed earlier today. I have to move my cursor to the right of the heading - where the "reverse P" anchor symbol would be - for it to appear, as if I had to know ahead of time it would be there. Can we make the anchor link show up whenever I hover over any of the heading area too? I think this is how anchor link hovers usually work on other websites, or at least that's how I intuitively think they work. |
Change https://go.dev/cl/619015 mentions this issue: |
setAnchors in site.js was used to add anchor links to article headers. Move that functionality to the related addPermalinks in godocs.js, so it executes after generateTOC instead of before. That way generateTOC can go back to using the full heading text as it did before CL 601055 and not need to deal with ignoring the '¶' symbol that is newly added. For golang/go#68596. Fixes golang/go#69816. Change-Id: I39334bd5635cd7af5ee0baeaf1ca06734eb4cb3f Reviewed-on: https://go-review.googlesource.com/c/website/+/618635 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
By now, the /js/godocs.js and /js/playground.js scripts are already loaded on all go.dev pages because they're included at the bottom of the root site.tmpl template. The layout template for blog pages also loads those scripts. That means /js/godocs.js runs twice, and that causes duplicate anchor links to be added to article headings. Remove the duplicate scripts, keeping only play.js which isn't already present in site.html. Update it to reuse the existing window.initFuncs mechanism. For golang/go#68596. For golang/go#69816. Change-Id: I709f4b8df30500bddbbf16f4ddd95f266f290472 Reviewed-on: https://go-review.googlesource.com/c/website/+/619015 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Hi again @hyangah @dmitshur - did you see my comment above? This is a closed issue so I'm worried the comment will be forgotten. If you must track this in an open issue, we could either reopen this one as "not fully implemented" or I can open a new one. Ideally it's an easy fix that doesn't require tracking. |
In particular, it's how the anchor links work on pkgsite (example). @mvdan I think you should just file a separate bug so it doesn't get dropped. |
Yep, this is still not on anyone's radar, so I've filed #70827. |
Reveal anchor links to headings, so users can copy the link to the specific part of the doc easily.
Before

After - the "¶" symbol appears when hover. On Chrome, right click on it will show the context menu so users can operate on the anchor link.

The text was updated successfully, but these errors were encountered: