Rename the table of contents settings

- font matter: tableofcontents -> toc
- config: tableOfContentsWordCount -> tocWordThreshold
This commit is contained in:
Steven Engler 2022-02-13 04:13:30 -05:00
parent 35f0af2f28
commit c0a6ab5ca0

View File

@ -11,7 +11,7 @@
{{- end }}
</div>
</div>
{{ if or (.Params.tableofcontents) (and (ne .Params.tableofcontents false) (isset .Site.Params "tableofcontentswordcount") (ge .Site.Params.TableOfContentsWordCount 0) (gt .WordCount .Site.Params.TableOfContentsWordCount)) }}
{{ if or (.Params.toc) (and (ne .Params.toc false) (isset .Site.Params "tocwordthreshold") (ge .Site.Params.TocWordThreshold 0) (gt .WordCount .Site.Params.TocWordThreshold)) }}
{{/* If the front matter parameter is true, show the toc */}}
{{/* Elif the front matter parameter is false, don't show the toc */}}
{{/* Elif the front matter parameter is not set, show the toc if the site parameter is set, non-negative, and less than the word count */}}
@ -21,6 +21,7 @@
<span class="table-of-contents-title">Table of Contents</span>
</summary>
{{ $toc := .TableOfContents -}}
{{/* Workaround for an extra layer of indentation (https://discourse.gohugo.io/t/2303) */}}
{{- $toc := replaceRE `<nav(.*)>(\s?)<ul>\s?<li>\s?<ul>` `<nav${1}>${2}<ul>` $toc -}}
{{- $toc := replaceRE `</ul>\s?</li>\s?</ul>(\s?)</nav>` `</ul>${1}</nav>` $toc -}}
{{- safeHTML $toc }}