mirror of
https://github.com/docker/docs.git
synced 2026-03-28 06:49:00 +07:00
- layouts/partials/ → layouts/_partials/ - layouts/shortcodes/ → layouts/_shortcodes/ - layouts/_default/_markup/ → layouts/_markup/ - layouts/_default/*.html → layouts/*.html (flatten _default/) - layouts/index.html → layouts/home.html - layouts/index.*.json/txt → layouts/home.*.json/txt - layouts/_default/index.llms.txt → layouts/home.llms.txt - layouts/tag/ → layouts/tags/ (match /tags/ URL path)
43 lines
1.3 KiB
HTML
43 lines
1.3 KiB
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 }}
|
|
<div data-pagefind-ignore class="not-prose">
|
|
<div class="pb-0 text-lg lg:pb-2">
|
|
{{ T "tableOfContents" }}
|
|
</div>
|
|
<nav class="toc">
|
|
{{ $root := (index page.Fragments.Headings 0).Headings }}
|
|
{{- template "walkHeadingFragments" $root }}
|
|
</nav>
|
|
</div>
|
|
{{- end }}
|
|
|
|
{{- define "walkHeadingFragments" }}
|
|
{{- $min := default 2 page.Params.toc_min }}
|
|
{{- $max := default 3 page.Params.toc_max }}
|
|
<ul class="pl-2">
|
|
{{- range . }}
|
|
{{- if and (ge .Level $min) (le .Level $max) }}
|
|
<li>
|
|
<a class="link lg:no-underline" href="#{{ .ID }}"
|
|
>{{ markdownify .Title }}</a
|
|
>
|
|
</li>
|
|
{{- end }}
|
|
{{- with .Headings }}
|
|
{{ template "walkHeadingFragments" . }}
|
|
{{- end }}
|
|
{{- end }}
|
|
</ul>
|
|
{{- end }}
|