From 7484d058f201af669cf1ae71900f71eda90166a0 Mon Sep 17 00:00:00 2001 From: Philip Mallegol-Hansen Date: Tue, 30 Apr 2024 22:46:39 -0700 Subject: [PATCH 1/2] Corrects logic for enabling ToC --- layouts/partials/toc.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html index 2656c6d..3d148a2 100644 --- a/layouts/partials/toc.html +++ b/layouts/partials/toc.html @@ -1,9 +1,8 @@ -{{ $toc := and ($.Site.Params.toc) (ge .WordCount $.Site.Params.tocWordCount) }} -{{ if isset .Params "toc" }} - {{ $toc = .Params.toc }} -{{ else }} - {{ $toc = true }} +{{ $toc := true }} +{{ if isset .Site.Params "toc" }} + {{ $toc = .Site.Params.toc }} {{ end }} +{{ $toc = and ($toc) (ge .WordCount .Site.Params.tocWordCount) }} {{ if $toc }} From 8c4d7defca48e7de32bafdaae3cecd8a2223a998 Mon Sep 17 00:00:00 2001 From: Philip Mallegol-Hansen Date: Wed, 1 May 2024 13:58:51 -0700 Subject: [PATCH 2/2] Improves ToC logic to account for both site and page configuration --- layouts/partials/toc.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html index 3d148a2..588d180 100644 --- a/layouts/partials/toc.html +++ b/layouts/partials/toc.html @@ -1,8 +1,12 @@ {{ $toc := true }} -{{ if isset .Site.Params "toc" }} - {{ $toc = .Site.Params.toc }} +{{ if isset .Params "toc" }} + {{ $toc = .Params.toc }} +{{ else }} + {{ $toc = ge .WordCount .Site.Params.tocWordCount }} + {{ if and (isset .Site.Params "toc") (not (.Site.Params.toc)) }} + {{ $toc = false }} + {{ end }} {{ end }} -{{ $toc = and ($toc) (ge .WordCount .Site.Params.tocWordCount) }} {{ if $toc }}