From 41c443dbf079e65ed69f57d3b9a5ce58dc403e6d Mon Sep 17 00:00:00 2001
From: earnest ma <me@earne.link>
Date: Fri, 11 Feb 2022 22:15:28 +0000
Subject: [PATCH] Add disableToc parameter to not show TOC on a page

---
 layouts/_default/single.html |    2 +-
 content/notes/editing.md     |    1 +
 layouts/index.html           |    2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/content/notes/editing.md b/content/notes/editing.md
index a9d7290..17730ef 100644
--- a/content/notes/editing.md
+++ b/content/notes/editing.md
@@ -48,6 +48,7 @@
 title: "Example Title"
 tags:
 - example-tag
+disableToc: true # do not show a table of contents on this page if enabled
 ---
 
 Rest of your content here...
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index a84ec91..9f9f877 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -22,7 +22,7 @@
           <li><a href="{{ .Permalink }}">{{ .LinkTitle | humanize }}</a></li>
           {{ end }}
       </ul>
-      {{if $.Site.Data.config.enableToc}}
+      {{ if (and $.Site.Data.config.enableToc (not (.Params.disableToc))) }}
       <aside class="mainTOC">
           <h3>Table of Contents</h3>
           {{ .TableOfContents }}
diff --git a/layouts/index.html b/layouts/index.html
index 06fcb95..0e2a9d1 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -13,7 +13,7 @@
         {{partial "darkmode.html" .}}
     </header>
     <article>
-        {{if $.Site.Data.config.enableToc}}
+        {{ if (and $.Site.Data.config.enableToc (not (.Params.disableToc))) }}
         <aside class="mainTOC">
             <h3>Table of Contents</h3>
             {{ .TableOfContents }}

--
Gitblit v1.10.0