From 0dc2dd5acd58848a3841c4a0080f0fe6e8edd9ac Mon Sep 17 00:00:00 2001 From: alexisben <alex@noesya.coop> Date: Wed, 23 Nov 2022 16:42:07 +0100 Subject: [PATCH] add home toc --- layouts/index.html | 7 ++++++ layouts/partials/toc/default.html | 40 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 layouts/partials/toc/default.html diff --git a/layouts/index.html b/layouts/index.html index 06c83700..623e340f 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 00000000..ae57cd0f --- /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 -}} + + -- GitLab