diff --git a/layouts/_partials/toc.html b/layouts/_partials/toc.html new file mode 100644 index 0000000..17b0bcb --- /dev/null +++ b/layouts/_partials/toc.html @@ -0,0 +1,94 @@ +{{/* Table of Contents */}} +{{/* TODO: toc bottom part should be able to hide */}} +{{- $toc := .Params.toc | default true -}} +{{- $tags := (T "tags") | default "Tags"}} +{{- $editThisPage := (T "editThisPage") | default "Edit this page"}} +{{- $backToTop := (T "backToTop") | default "Scroll to top" -}} + + + +{{/* TOC subheadings component. This is a recursive component that renders a list of headings. */}} +{{- define "toc-subheading" -}} + {{- $headings := .headings -}} + {{- $level := .level -}} + {{- if ge $level 6 -}} + {{ return }} + {{- end -}} + + {{- $padding := (mul $level 4) -}} + {{- $class := cond (eq $level 0) "hx:font-medium" (printf "hx:ltr:pl-%d hx:rtl:pr-%d" $padding $padding) -}} + + {{- range $headings }} + {{- if .Title }} +
  • + + {{- .Title | safeHTML | plainify | htmlUnescape }} + +
  • + {{- end -}} + {{- with .Headings -}} + {{ template "toc-subheading" (dict "headings" . "level" (add $level 1)) }} + {{- end -}} + + {{- end -}} +{{- end -}}