From e5ba0272de82594290cbfcf6ef99e985c62d485a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Joly?= <7347374+cljoly@users.noreply.github.com> Date: Fri, 27 Aug 2021 17:29:50 +0000 Subject: [PATCH] Never display the ToC when it would be empty (#532) --- layouts/partials/toc.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html index 42f7e615..f6055c61 100644 --- a/layouts/partials/toc.html +++ b/layouts/partials/toc.html @@ -1,13 +1,13 @@ +{{- $headers := findRE "(.|\n])+?" .Content -}} +{{- $has_headers := ge (len $headers) 1 -}} +{{- if $has_headers -}}
{{- i18n "toc" | default "Table of Contents" }}
-
- {{- $headers := findRE "(.|\n])+?" .Content -}} - {{- $has_headers := ge (len $headers) 1 -}} - {{- if $has_headers -}} +
{{- $largest := 6 -}} {{- range $headers -}} {{- $headerLevel := index (findRE "[1-6]" . 1) 0 -}} @@ -87,7 +87,7 @@ {{- end -}} {{- end }} - {{- end }}
+{{- end }}