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" . -}}

{{ i18n "table_of_contents" }}

+{{- end -}} diff --git a/layouts/partials/post/toc.html b/layouts/partials/post/toc.html index 882c25fc1..bbcd718f1 100644 --- a/layouts/partials/post/toc.html +++ b/layouts/partials/post/toc.html @@ -1,12 +1,9 @@ -{{- $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" . -}}

{{- i18n "table_of_contents" -}}

- {{ $toc }} + {{ .TableOfContents }}
{{- end -}} diff --git a/layouts/partials/sidebar/toc.html b/layouts/partials/sidebar/toc.html index 7bd581b22..1c205066d 100644 --- a/layouts/partials/sidebar/toc.html +++ b/layouts/partials/sidebar/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" . -}}
@@ -11,7 +8,7 @@

{{ i18n "table_o

- {{ $toc }} + {{ .TableOfContents }}