diff options
Diffstat (limited to 'layouts/_default/list.html')
-rw-r--r-- | layouts/_default/list.html | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 476b1fa..23cb596 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -6,6 +6,12 @@ {{ define "toc" }} <ul id="toc" class="toc-list-h1"> + {{ $maxDepth := 0 }} + {{ with $.Site.Params.maxMenuDepth }} + {{ $maxDepth = . }} + {{ else }} + {{ $maxDepth = 2 }} + {{ end }} {{ $headers := slice }} {{ with .Site.RegularPages }} {{ $headers = partial "funcs/toc_from_pages" . }} @@ -13,14 +19,23 @@ {{ range $headers }} <li> <a href="#{{ .id }}" class="toc-h{{ .level }} toc-link" data-title="{{ .title }}">{{ .title }}</a> - {{if .sub }} + {{ if and (ge $maxDepth 2) .sub }} <ul class="toc-list-h2"> - {{range .sub}} - <li><a href="#{{ .id }}" class="toc-h{{ .level }} toc-link" data-title="{{ .title }}">{{ .title }}</a></li> - {{end}} + {{ range .sub }} + <li> + <a href="#{{ .id }}" class="toc-h{{ .level }} toc-link" data-title="{{ .title }}">{{ .title }}</a> + {{ if and (ge $maxDepth 3) .sub }} + <ul class="toc-list-h3"> + {{ range .sub }} + <li><a href="#{{ .id }}" class="toc-h{{ .level }} toc-link" data-title="{{ .title }}">{{ .title }}</a></li> + {{ end }} + </ul> + {{ end }} + </li> + {{ end }} </ul> - {{end}} + {{ end }} </li> - {{end}} + {{ end }} </ul> -{{ end }}
\ No newline at end of file +{{ end }} |