Skip to content

Commit

Permalink
Add optional levels parameter to toctree (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodmillman authored Mar 7, 2024
1 parent 91de393 commit 1701257
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion layouts/shortcodes/toctree.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@

*/}}

{{- $levels := 3 }}
{{- with (.Get "levels") }}
{{- $levels = . }}
{{- end }}
<div class="toctree-wrapper">
{{- range $section := .Page.Sections }}
<ul>
<li class="toctree-l1"><a href="{{ $section.RelPermalink }}">{{ $section.Title | safeHTML }}</a></li>
{{- if gt $levels 1 }}
{{- range $page := .RegularPages }}
<ul>
<li class="toctree-l2"><a href="{{ $page.RelPermalink }}">{{ $page.Title }}</a></li>
{{- if gt $levels 2 }}
<ul>
{{- range .Fragments.Headings -}}
{{- range .Fragments.Headings -}}
{{/* H2 */}}
{{- range .Headings }}
<li class="toctree-l3">
Expand All @@ -25,8 +31,10 @@
{{- end -}}
{{- end }}
</ul>
{{- end }}
</ul>
{{- end }}
{{- end }}
</ul>
{{- end }}
</div>

0 comments on commit 1701257

Please sign in to comment.