2024-11-09 20:12:57 +00:00
|
|
|
{{/* {{- $startLevel := 2 -}}
|
|
|
|
{{- $endLevel := 3 -}}
|
|
|
|
{{ with .Param "markup.tableOfContents.startLevel" }}
|
|
|
|
{{- $startLevel = . }}
|
|
|
|
{{- end }}
|
|
|
|
{{ with .Param "markup.tableOfContents.endLevel" }}
|
|
|
|
{{- $endLevel = . }}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{ debug.Dump ($startLevel) }}
|
|
|
|
{{ debug.Dump ($endLevel) }}
|
|
|
|
|
2024-10-15 08:09:14 +00:00
|
|
|
<nav class="table-of-contents" id="TableOfContents">
|
|
|
|
<h2 class="table-of-contents__title">Table of Contents</h2>
|
2024-11-09 20:12:57 +00:00
|
|
|
{{- template "headings" (dict "headings" (index .Fragments.Headings 0) "startLevel" $startLevel "endLevel" $endLevel) }}
|
2024-10-15 08:09:14 +00:00
|
|
|
</nav>
|
|
|
|
|
|
|
|
{{- define "headings" }}
|
2024-11-09 20:12:57 +00:00
|
|
|
{{- $startLevel := .startLevel -}}
|
|
|
|
{{- $endLevel := .endLevel -}}
|
|
|
|
{{- with .headings }}
|
|
|
|
{{- if and (.Title) (ge .Level $startLevel) (le .Level $endLevel) -}}
|
2024-10-15 08:09:14 +00:00
|
|
|
{{ print (strings.Repeat (sub .Level 1) "\t") }}<li data-depth="{{sub .Level 1}}">
|
|
|
|
{{ print (strings.Repeat (sub .Level 1) "\t") }}<a href="#{{.ID}}">{{.Title | htmlUnescape}}</a>
|
|
|
|
{{- if .Headings }}
|
|
|
|
{{ print (strings.Repeat (sub .Level 1) "\t") }}<ol data-depth="{{sub .Level 1}}">
|
|
|
|
{{- range $k, $v := .Headings }}
|
2024-11-09 20:12:57 +00:00
|
|
|
{{- template "headings" (dict "headings" $v "startLevel" $startLevel "endLevel" $endLevel) }}
|
2024-10-15 08:09:14 +00:00
|
|
|
{{- end }}
|
|
|
|
{{ print (strings.Repeat (sub .Level 1) "\t") }}</ol>
|
|
|
|
{{- end }}
|
|
|
|
{{ print (strings.Repeat (sub .Level 1) "\t") }}</li>
|
|
|
|
{{- else }}
|
|
|
|
{{- if .Headings -}}
|
|
|
|
{{ print (strings.Repeat .Level "\t") }}<ol data-depth="{{.Level}}">
|
|
|
|
{{- range $k, $v := .Headings }}
|
2024-11-09 20:12:57 +00:00
|
|
|
{{- template "headings" (dict "headings" $v "startLevel" $startLevel "endLevel" $endLevel) }}
|
2024-10-15 08:09:14 +00:00
|
|
|
{{- end }}
|
|
|
|
{{ print (strings.Repeat .Level "\t") }}</ol>
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2024-11-09 20:12:57 +00:00
|
|
|
{{- end }}
|
|
|
|
{{- end }} */}}
|
|
|
|
{{
|
|
|
|
(
|
|
|
|
replace
|
|
|
|
.TableOfContents
|
|
|
|
"<nav id=\"TableOfContents\">\n"
|
|
|
|
"<nav class=\"table-of-contents\" id=\"TableOfContents\">\n<h2 class=\"table-of-contents__title\">Table of Contents</h2>\n"
|
|
|
|
)
|
|
|
|
| safeHTML
|
|
|
|
}}
|