Skip to content

Commit 1701257

Browse files
Add optional levels parameter to toctree (#531)
1 parent 91de393 commit 1701257

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

layouts/shortcodes/toctree.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,21 @@
88

99
*/}}
1010

11+
{{- $levels := 3 }}
12+
{{- with (.Get "levels") }}
13+
{{- $levels = . }}
14+
{{- end }}
1115
<div class="toctree-wrapper">
1216
{{- range $section := .Page.Sections }}
1317
<ul>
1418
<li class="toctree-l1"><a href="{{ $section.RelPermalink }}">{{ $section.Title | safeHTML }}</a></li>
19+
{{- if gt $levels 1 }}
1520
{{- range $page := .RegularPages }}
1621
<ul>
1722
<li class="toctree-l2"><a href="{{ $page.RelPermalink }}">{{ $page.Title }}</a></li>
23+
{{- if gt $levels 2 }}
1824
<ul>
19-
{{- range .Fragments.Headings -}}
25+
{{- range .Fragments.Headings -}}
2026
{{/* H2 */}}
2127
{{- range .Headings }}
2228
<li class="toctree-l3">
@@ -25,8 +31,10 @@
2531
{{- end -}}
2632
{{- end }}
2733
</ul>
34+
{{- end }}
2835
</ul>
2936
{{- end }}
37+
{{- end }}
3038
</ul>
3139
{{- end }}
3240
</div>

0 commit comments

Comments
 (0)