diff --git a/layouts/partials/functions/toc.html b/layouts/partials/functions/toc.html new file mode 100644 index 000000000..ce65d3973 --- /dev/null +++ b/layouts/partials/functions/toc.html @@ -0,0 +1,4 @@ +{{- $enable := and (default true .Params.toc) (default true .Site.Params.toc) -}} +{{- $toc := .TableOfContents -}} +{{- $valid := and $toc (and (ne $toc "") (gt .WordCount .Site.Params.tocWordCount)) -}} +{{- return and $enable $valid -}} diff --git a/layouts/partials/post/panel/toc.html b/layouts/partials/post/panel/toc.html index ae58d4697..52112c7e8 100644 --- a/layouts/partials/post/panel/toc.html +++ b/layouts/partials/post/panel/toc.html @@ -1,7 +1,4 @@ -{{- $enable := and (default true .Params.toc) (default true .Site.Params.toc) -}} -{{- $toc := .TableOfContents -}} -{{- $valid := and $toc (and (ne $toc "") (gt .WordCount .Site.Params.tocWordCount)) -}} -{{- if and $enable $valid -}} +{{- if partial "functions/toc" . -}} diff --git a/layouts/partials/post/toc-wrapper.html b/layouts/partials/post/toc-wrapper.html index fa0d10cb7..3b2e940b2 100644 --- a/layouts/partials/post/toc-wrapper.html +++ b/layouts/partials/post/toc-wrapper.html @@ -1,4 +1,6 @@ +{{- if partial "functions/toc" . -}}