website/_content/js
Hana (Hyang-Ah) Kim 0597db8f98 _content: add anchor links to article headers
These anchor links allow users to copy the links for jumping tos
the specific sections easily.

We use javascript to add these links to handle both .html
and .md file format contents. If we had only markdown-based
contents, we could've adjusted the markdown-to-html renderer
instead of relying on javascript. Alternatively, we can try
to rewrite the html in a later pass, but html dom query and
rewrite is simpler in JS.

In order to minimize styling changes in the header text,
we set up the anchor on ¶ symbol that appears only on hover.
This is similar to how pkg.go.dev handles header anchor links.

Adjust the code for TOC generation (in godocs.js), since
now the heading elements include ¶, we want to drop it but
use the first part of the heading elements when compiling
TOC.

Fixes golang/go#68596

Change-Id: Idfe4734c54c636e426b579fdcd697156e87b5747
Reviewed-on: https://go-review.googlesource.com/c/website/+/601055
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-07-25 22:27:21 +00:00
..
carousels.js go.dev: merge go.dev/_content into root _content 2021-11-22 16:42:59 +00:00
copypaste.js _content: Copy code snippets 2022-12-05 14:51:44 +00:00
d3.js _content/doc: add GC guide for Go 1.19 2022-07-12 18:20:47 +00:00
godocs.js _content: add anchor links to article headers 2024-07-25 22:27:21 +00:00
hats.js _content/js: adjust HaTS sample rate, disable on playground 2022-09-22 17:52:25 +00:00
index.js go.dev: merge go.dev/_content into root _content 2021-11-22 16:42:59 +00:00
jquery-linedtextarea.js talks: serve go.dev/talks for talks.golang.org content 2021-11-22 20:36:15 +00:00
jquery.js _content/js: update jQuery 2023-06-05 15:00:37 +00:00
jumplinks.js _content: Learn page redesign 2023-03-09 17:11:53 +00:00
misc.js _content: fix solutions pages subnavigation 2022-03-17 15:12:24 +00:00
play.js go.dev: merge go.dev/_content into root _content 2021-11-22 16:42:59 +00:00
playground.js tour: call 'done' callback after Run, on message Kind 'system' 2024-01-19 15:36:06 +00:00
playsite.js _content: do not run playground code on page load 2022-05-25 16:59:47 +00:00
searchBox.js all: fix and test for references to github.com/golang/go/issues and wiki 2023-12-20 17:31:44 +00:00
site.js _content: add anchor links to article headers 2024-07-25 22:27:21 +00:00