From c8a6a32bf2adcfacafe5d28d0789eebadca2b48f Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 10 Feb 2024 17:41:43 +0100 Subject: [PATCH] Added TableOfContents to every blog post --- hugo.toml | 4 +++- layouts/blog/single.html | 3 +++ static/base.css | 12 +++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/hugo.toml b/hugo.toml index 2e1b079..5399669 100644 --- a/hugo.toml +++ b/hugo.toml @@ -7,7 +7,9 @@ pygmentsUseClasses = true unsafe = true [markup.tableOfContents] -ordered = true +ordered = false +endLevel = 2 +startLevel = 1 [taxonomies] tags = 'keywords' diff --git a/layouts/blog/single.html b/layouts/blog/single.html index 74d85c5..d094ec9 100644 --- a/layouts/blog/single.html +++ b/layouts/blog/single.html @@ -12,6 +12,9 @@ {{.Date.Format "January 2, 2006"}} + {{.Content}} {{ partial "footer.html" . }} diff --git a/static/base.css b/static/base.css index 74d8bd4..ec9a31a 100644 --- a/static/base.css +++ b/static/base.css @@ -87,17 +87,20 @@ body > main { display: flex; flex-direction: column; } -nav { + +/* TOP NAVBAR */ +/* NOTE: manually exclude TOC, as it breaks the .org TOC otherwise*/ +nav:not(#TableOfContents) { width: 100%; } -nav ul { +nav:not(#TableOfContents) ul { text-decoration: none; display: flex; gap: 0.4rem; margin: 0; padding: 0.4rem; } -nav ul li { +nav:not(#TableOfContents) ul li { display: block; } @@ -323,6 +326,7 @@ div.sourceCode:hover::after,pre.example:hover::after, figure:hover::after,div.sr } } +/* LIST ITEMS */ a.category, li.stub { display: flex; flex-direction: column; @@ -380,6 +384,7 @@ li.stub .tags li a { text-decoration: underline; } +/* PAGE FOOTER */ footer { display: flex; flex-direction: column; @@ -389,6 +394,7 @@ footer * { text-align: center; } +/* HELPERS */ .nopad { padding: 0; } -- 2.38.5