From cd7e2088d564023b073a458282e3a63b7a108c0b Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Fri, 23 Sep 2022 10:17:28 -0700 Subject: [PATCH] feat: hide TOC when no headers (closes #204) --- content/_index.md | 3 ++- layouts/partials/toc.html | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/content/_index.md b/content/_index.md index 5b43f8ea8..5c7b838b7 100644 --- a/content/_index.md +++ b/content/_index.md @@ -1,5 +1,6 @@ --- -title: 🪴 Quartz 3.3 +title: 🪴 Quartz 3. +enableToc: false --- Host your second brain and [digital garden](https://jzhao.xyz/posts/networked-thought) for free. Quartz features diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html index c1c6d2a4c..acad6fe70 100644 --- a/layouts/partials/toc.html +++ b/layouts/partials/toc.html @@ -1,4 +1,5 @@ -{{ if (and $.Site.Data.config.enableToc (ne .Params.enableToc false) (gt .WordCount 250)) }} +{{ $hasHeaders := gt (len (findRE "(.|\n)*?" .Content)) 0 }} +{{ if (and $.Site.Data.config.enableToc (ne .Params.enableToc false) $hasHeaders) }}