Jacky Zhao
2022-04-05 e245505082eedb720873e20331c36952ded67d09
feat: hide toc for short notes
1 files added
2 files modified
26 ■■■■■ changed files
layouts/_default/single.html 9 ●●●● patch | view | raw | blame | history
layouts/index.html 9 ●●●● patch | view | raw | blame | history
layouts/partials/toc.html 8 ●●●●● patch | view | raw | blame | history
layouts/_default/single.html
@@ -22,14 +22,7 @@
          <li><a href="{{ .Permalink }}">{{ .LinkTitle | humanize }}</a></li>
          {{ end }}
      </ul>
      {{ if (and $.Site.Data.config.enableToc (ne .Params.enableToc false)) }}
      <aside class="mainTOC">
          <details {{ if $.Site.Data.config.openToc }}open {{ end }}>
            <summary>Table of Contents</summary>
            {{ .TableOfContents }}
          </details>
      </aside>
      {{end}}
      {{partial "toc.html" .}}
      {{partial "textprocessing.html" . }}
    </article>
    {{partial "footer.html" .}}
layouts/index.html
@@ -13,14 +13,7 @@
        {{partial "darkmode.html" .}}
    </header>
    <article>
        {{ if (and $.Site.Data.config.enableToc (ne .Params.enableToc false)) }}
        <aside class="mainTOC">
            <details {{ if $.Site.Data.config.openToc }}open {{ end }}>
                <summary>Table of Contents</summary>
                {{ .TableOfContents }}
            </details>
        </aside>
        {{end}}
        {{partial "toc.html" .}}
        {{partial "textprocessing.html" . }}
    </article>
    {{partial "footer.html" .}}
layouts/partials/toc.html
New file
@@ -0,0 +1,8 @@
{{ if (and $.Site.Data.config.enableToc (ne .Params.enableToc false) (gt .WordCount 250)) }}
<aside class="mainTOC">
    <details {{ if $.Site.Data.config.openToc }}open {{ end }}>
        <summary>Table of Contents</summary>
        {{ .TableOfContents }}
    </details>
</aside>
{{end}}