[x/blog] _template: make headings self-hyperlinks

This makes it easy to get a section link by clicking on the section heading.
Also add support for {#ID} in Markdown, in addition to the auto-generated anchors.

Change-Id: Idd9d6c7cec2395f86808220c885861dc6c45e9d6
Reviewed-on: https://go-review.googlesource.com/c/blog/+/314173
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
X-Blog-Commit: d5f68129df4102cd8ec637a7521d733978bc0c76
This commit is contained in:
Russ Cox 2021-04-27 12:04:44 -04:00
Родитель 933e4e0efd
Коммит 2cc45bf07e
3 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -6,7 +6,7 @@ Summary: Please take the 2020 Go Developer Survey. We want to hear from you!
Alice Merrick
amerrick@google.com
## Help shape the future of Go
## Help shape the future of Go {#help}
Since 2016, thousands of Gophers around the world have helped the Go project
by sharing their thoughts via our annual Go Developer Survey.

Просмотреть файл

@ -29,7 +29,9 @@
{{end}}
{{define "section"}}
<h4 id="TOC_{{.FormattedNumber}}">{{.Title}}</h4>
{{$name := printf "TOC_%s" .FormattedNumber}}
{{with .ID}}{{$name = .}}{{end}}
<a {{with .ID}}name="{{.}}" {{end}}class="head" href="#{{$name}}"><h4 id="TOC_{{.FormattedNumber}}">{{.Title}}</h4></a>
{{range .Elem}}{{elem $.Template .}}{{end}}
{{end}}

Просмотреть файл

@ -33,6 +33,13 @@
overflow-wrap: normal;
padding: 0;
}
a.head {
color: black;
text-decoration: none !important;
}
a.head:hover {
text-decoration: underline;
}
@media print {
#sidebar { display: none; }
}