diff --git a/layouts/index.html b/layouts/index.html index 06c83700254995fb8ba5488dcd528b31ff19efa5..623e340fe6bad01ed04794358d98228fcf464b86 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -2,6 +2,13 @@ {{ partial "home/hero.html" . }} <div class="document-content"> + {{ partial "toc/container.html" + (dict + "toc" "toc/default.html" + "context" . + ) + }} + {{- if .Params.blocks }} {{- partial "blocks/list.html" . -}} diff --git a/layouts/partials/toc/default.html b/layouts/partials/toc/default.html new file mode 100644 index 0000000000000000000000000000000000000000..ae57cd0f5adb72ebaa6b374c6581d3cca8a458b5 --- /dev/null +++ b/layouts/partials/toc/default.html @@ -0,0 +1,40 @@ +{{- $show_aside := false -}} + +{{- $has_blocks := false -}} +{{- range .context.Params.blocks -}} + {{- $has_blocks = true -}} + {{- if .title -}} + {{- $show_aside = true -}} + {{- end -}} +{{- end -}} + +{{- if .context.Pages -}} + {{- if eq $has_blocks false -}} + {{- $show_aside = true -}} + {{- end -}} +{{- end -}} + +{{- if .context.Content -}} + {{- if eq $has_blocks false -}} + {{- $show_aside = true -}} + {{- end -}} +{{- end -}} + +{{- if .category -}} + {{- if eq $has_blocks false -}} + {{- $show_aside = true -}} + {{- end -}} +{{- end -}} + +{{- if $show_aside }} + <nav class="toc toc-pages" id="nav-toc" aria-labelledby="toc-title"> + <ol> + {{- if .context.Params.blocks -}} + {{- partial "blocks/toc.html" .context.Params.blocks -}} + {{- end -}} + </ol> + </nav> + +{{ end -}} + +