2017-11-02 16:39:45 +01:00
|
|
|
{{ $headings := findRE "<h2.*?>(.|\n])+?</h2>" .Content }}
|
|
|
|
{{ if ge (len $headings) 2 }}
|
|
|
|
<nav class="toc" aria-labelledby="toc-heading">
|
2020-06-01 20:47:51 +02:00
|
|
|
<h2 id="toc-heading">{{ T "table_of_contents" }}</h2>
|
2017-11-02 16:39:45 +01:00
|
|
|
<ol>
|
|
|
|
{{ range $headings }}
|
|
|
|
<li>
|
2019-02-26 17:16:01 +01:00
|
|
|
{{ $id := findRE "id=\".*\"" . }}
|
|
|
|
{{ $id = index $id 0 }}
|
|
|
|
{{ $id = strings.TrimPrefix "id=\"" $id }}
|
|
|
|
{{ $id = strings.TrimSuffix "\"" $id }}
|
|
|
|
<a href="#{{ $id }}">
|
2017-11-02 16:39:45 +01:00
|
|
|
{{ . | htmlUnescape | plainify }}
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
{{ end }}
|
|
|
|
</ol>
|
|
|
|
</nav>
|
|
|
|
{{ end }}
|