From 3d6a95434ca9b042f7cd1c844a86bd87493f7dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Tue, 15 Feb 2022 20:28:29 +0100 Subject: [PATCH] nav: only show toc if the page has headings #182 --- layouts/partials/header.html | 3 ++- layouts/partials/menu.html | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/layouts/partials/header.html b/layouts/partials/header.html index af18100501..ef40e6d5e4 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -44,7 +44,8 @@ {{- end }} {{- $defaultDisableToc := .Site.Params.disableToc | default false }} {{- $currentDisableToc := .Params.disableToc | default $defaultDisableToc }} - {{- $toc := (and (not $currentDisableToc) (not .Params.chapter)) }} + {{- $hastoc := not (eq 0 (int (len (.TableOfContents | plainify)))) }} + {{- $toc := (and $hastoc (not $currentDisableToc) (not .Params.chapter)) }}