fix: use <ol> for TOC. And Disable TOC by default for now

This commit is contained in:
Jimmy 2021-06-21 17:41:53 +02:00
parent 85f8577aa2
commit e1c1bef239
3 changed files with 14 additions and 8 deletions

View File

@ -196,12 +196,14 @@
color: var(--card-text-color-main); color: var(--card-text-color-main);
#TableOfContents { #TableOfContents {
ul { ol {
counter-reset: item;
list-style-type: none; list-style-type: none;
counter-reset: section; padding: 0;
margin: 0;
} }
& > ul { & > li {
padding: 0; padding: 0;
margin: 0; margin: 0;
} }
@ -211,13 +213,13 @@
padding: 5px; padding: 5px;
&::before { &::before {
counter-increment: section; counter-increment: item;
content: counters(section, ".") ". "; content: counters(item, ".") ". ";
font-weight: bold; font-weight: bold;
margin-right: 5px; margin-right: 5px;
} }
& > ul { & > ol {
margin-top: 10px; margin-top: 10px;
padding-left: 10px; padding-left: 10px;
margin-bottom: -5px; margin-bottom: -5px;

View File

@ -42,7 +42,7 @@ params:
article: article:
math: false math: false
toc: true toc: false
license: license:
enabled: true enabled: true
default: Licensed under CC BY-NC-SA 4.0 default: Licensed under CC BY-NC-SA 4.0
@ -146,5 +146,9 @@ related:
weight: 200 weight: 200
markup: markup:
tableOfContents:
endLevel: 4
ordered: true
startLevel: 2
highlight: highlight:
noClasses: false noClasses: false

View File

@ -1,5 +1,5 @@
{{ define "body-class" }} {{ define "body-class" }}
{{ $TOCEnabled := default (default true .Site.Params.article.toc) .Params.toc }} {{ $TOCEnabled := default (default false .Site.Params.article.toc) .Params.toc }}
{{- .Scratch.Set "hasTOC" (and (ge (len .TableOfContents) 100) $TOCEnabled) -}} {{- .Scratch.Set "hasTOC" (and (ge (len .TableOfContents) 100) $TOCEnabled) -}}
article-page keep-sidebar{{ if (.Scratch.Get "hasTOC") }} has-toc{{ end }} article-page keep-sidebar{{ if (.Scratch.Get "hasTOC") }} has-toc{{ end }}
{{ end }} {{ end }}