toc-autonumbering

borrowed from https://codingnconcepts.com/hugo/auto-number-headings-hugo/
This commit is contained in:
T2hhbmEK
2023-01-22 04:45:17 +08:00
parent 9e657da94a
commit 4e4d0a6388
4 changed files with 23 additions and 3 deletions

View File

@@ -32,6 +32,7 @@ body {
.headings--one-size {
h1,
h2,
.toc-title,
h3,
h4,
h5,
@@ -45,6 +46,7 @@ body {
h1,
h2,
.toc-title,
h3 {
font-size: 1.4rem;
}

View File

@@ -126,3 +126,17 @@ h1:hover a, h2:hover a, h3:hover a, h4:hover a {
.footnotes {
color: transparentize($color, .5);
}
/* Auto Numbering */
// https://codingnconcepts.com/hugo/auto-number-headings-hugo/
body {counter-reset: h2}
h2 {counter-reset: h3}
h3 {counter-reset: h4}
h4 {counter-reset: h5}
article[autonumbering] h2:before {counter-increment: h2; content: counter(h2) " "}
article[autonumbering] h3:before {counter-increment: h3; content: counter(h2) "." counter(h3) " "}
article[autonumbering] h4:before {counter-increment: h4; content: counter(h2) "." counter(h3) "." counter(h4) " "}
article[autonumbering] .table-of-contents ul { counter-reset: item }
article[autonumbering] .table-of-contents li a:before { content: counters(item, ".") " "; counter-increment: item }