diff --git a/themes/hextra/layouts/partials/toc.html b/themes/hextra/layouts/partials/toc.html
index 02cf98da..ce070045 100644
--- a/themes/hextra/layouts/partials/toc.html
+++ b/themes/hextra/layouts/partials/toc.html
@@ -12,7 +12,9 @@
{{ $onThisPage }}
{{- range . -}}
- {{- with .Headings -}}{{ template "toc-subheading" (dict "headings" . "level" 0) }}{{- end -}}
+ {{- with .Headings -}}
+ {{- template "toc-subheading" (dict "headings" . "level" 1 "maxDepth" 2) -}}
+ {{- end -}}
{{- end -}}
{{- end -}}
@@ -54,28 +56,20 @@
{{ end -}}
-{{/* TOC subheadings component. This is a recursive component that renders a list of headings. */}}
+{{/* Define the toc-subheading template */}}
{{- define "toc-subheading" -}}
- {{- $headings := .headings -}}
{{- $level := .level -}}
- {{- if ge $level 6 -}}
- {{ return }}
- {{- end -}}
-
- {{- $padding := (mul $level 4) -}}
- {{- $class := cond (eq $level 0) "hx-font-semibold" (printf "ltr:hx-pl-%d rtl:hx-pr-%d" $padding $padding) -}}
-
- {{- range $headings }}
- {{- if .Title }}
-
-
- {{- .Title | safeHTML | plainify | htmlUnescape }}
-
+ {{- $maxDepth := .maxDepth -}}
+ {{- range .headings -}}
+ {{- if le $level $maxDepth -}}
+
+ {{ .Title }}
+ {{- with .Headings -}}
+
+ {{- template "toc-subheading" (dict "headings" . "level" (add $level 1) "maxDepth" $maxDepth) -}}
+
+ {{- end -}}
{{- end -}}
- {{- with .Headings -}}
- {{ template "toc-subheading" (dict "headings" . "level" (add $level 1)) }}
- {{- end -}}
-
{{- end -}}
{{- end -}}