layouts/_partials/pagemeta.html
{{- /* Renders a table of contents (ToC) for the page. - Uses .Fragments.Headings to generate a nested ToC if headings exist and notoc is not set to true. - Limits heading levels to a min and max range ($min and $max). - Wraps the ToC in a data-pagefind-ignore container to exclude it from search indexing. - Includes a recursive template (walkHeadingFragments) to handle nested headings. */ -}} {{- $toc := false }} {{- with .Fragments }} {{- $toc = and (ne page.Params.notoc true) .Headings }} {{- end }} {{- with $toc }}
{{ T "tableOfContents" }}
{{- end }} {{- define "walkHeadingFragments" }} {{- $min := default 2 page.Params.toc_min }} {{- $max := default 3 page.Params.toc_max }} {{- range . }} {{- if and (ge .Level $min) (le .Level $max) }} - {{ markdownify .Title }} {{- end }} {{- with .Headings }} {{ template "walkHeadingFragments" . }} {{- end }} {{- end }} {{- end }}