From 145401dd6b9161e1316a338ca54f3a35d8d696d0 Mon Sep 17 00:00:00 2001
From: John D. Rowell <me@jdrowell.com>
Date: Mon, 23 Feb 2026 14:28:17 +0000
Subject: [PATCH] Added TOC support (#985)

---
 layouts/posts/single.html  |    2 ++
 i18n/en.toml               |    3 +++
 layouts/_partials/toc.html |    9 +++++++++
 3 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/i18n/en.toml b/i18n/en.toml
index 987586d..633a206 100644
--- a/i18n/en.toml
+++ b/i18n/en.toml
@@ -62,3 +62,6 @@
 
 [link_to_heading]
 other = "Link to heading"
+
+[entry_toc]
+other = "Table of Contents"
diff --git a/layouts/_partials/toc.html b/layouts/_partials/toc.html
new file mode 100644
index 0000000..5bebba2
--- /dev/null
+++ b/layouts/_partials/toc.html
@@ -0,0 +1,9 @@
+{{- $toc := default .Site.Params.Entry.toc .Params.toc -}}
+{{- $tocOpen := default .Site.Params.Entry.tocOpen .Params.tocOpen -}}
+
+{{- if $toc }}
+<details class="entry__toc toc" {{ if $tocOpen }}open{{ end }}>
+	<summary class="toc__title">{{- T "entry_toc" -}}</summary>
+	{{ .TableOfContents }}
+</details>
+{{- end }}
diff --git a/layouts/posts/single.html b/layouts/posts/single.html
index 03a6dc3..e2f39e7 100644
--- a/layouts/posts/single.html
+++ b/layouts/posts/single.html
@@ -31,6 +31,8 @@
         </div>
       </header>
 
+      {{ partial "toc.html" . }}
+
       <div class="post-content">
         {{ if .Params.featuredImage }}
           <img src="{{ .Params.featuredImage | relURL }}" alt="Featured image"/>

--
Gitblit v1.10.0