2023-11-03 22:11:00 +00:00
|
|
|
{{- if or (eq .Kind "taxonomy") (eq .Kind "term") }}
|
2023-10-30 18:11:39 +00:00
|
|
|
{{- $lastCapital := "" }}
|
2023-11-03 22:11:00 +00:00
|
|
|
{{- $pages := slice }}
|
|
|
|
{{- if eq .Kind "taxonomy" }}
|
2023-12-01 00:03:51 +00:00
|
|
|
{{- $pages = partialCached "partials/pageHelper/taxonomyPages.html" . . }}
|
2023-11-03 22:11:00 +00:00
|
|
|
{{- else if eq .Kind "term" }}
|
2023-12-01 00:03:51 +00:00
|
|
|
{{- $pages = partialCached "partials/pageHelper/termPages.html" . . }}
|
2023-10-30 18:11:39 +00:00
|
|
|
{{- end }}
|
2023-11-03 22:11:00 +00:00
|
|
|
{{- $toc_pages := "" }}
|
2023-12-01 00:03:51 +00:00
|
|
|
{{- range $pages }}
|
2023-10-30 18:11:39 +00:00
|
|
|
{{- $capital := substr .Title 0 1 | upper }}
|
|
|
|
{{- if ne $lastCapital $capital }}
|
2023-11-03 22:11:00 +00:00
|
|
|
{{- $toc_pages = printf "%s <li><a href=\"#%s\">%s</a></li>\n" $toc_pages ($capital | plainify | anchorize) $capital }}
|
2023-10-30 18:11:39 +00:00
|
|
|
{{- end }}
|
|
|
|
{{- $lastCapital = $capital }}
|
|
|
|
{{- end }}
|
2023-10-30 20:05:00 +00:00
|
|
|
{{- $toc := trim (partial "toc.html" .) " \n\r\t" }}
|
2023-11-03 22:11:00 +00:00
|
|
|
{{- if and (not $toc) $toc_pages }}
|
2023-10-30 20:05:00 +00:00
|
|
|
{{- $toc = printf "<nav id=\"TableOfContents\"></nav>" }}
|
|
|
|
{{- end }}
|
2023-11-03 22:11:00 +00:00
|
|
|
{{- if and $toc $toc_pages }}
|
2023-10-30 20:05:00 +00:00
|
|
|
{{- $toc = replaceRE "^(<nav id=\"TableOfContents\">)[\\s]*" "${1}\n <ul>\n" $toc }}
|
|
|
|
{{- $toc = replaceRE "^(<nav id=\"TableOfContents\">[\\s]*<ul>)[\\s]*<ul>[\\n\\r]*" "${1}\n" $toc }}
|
|
|
|
{{- $toc = replaceRE "[\\s]*(</nav>)$" "\n </ul>\n${1}" $toc }}
|
|
|
|
{{- $toc = replaceRE "[ \\t]*</ul>[\\s]*(</ul>[\\s]*</nav>)$" " ${1}" $toc }}
|
2023-11-03 22:11:00 +00:00
|
|
|
{{- $toc = replaceRE "([ \\t]*</ul>[\\s]*</nav>)$" (printf "%s${1}" $toc_pages) $toc }}
|
2023-10-30 20:05:00 +00:00
|
|
|
{{- end }}
|
|
|
|
{{ $toc | safeHTML }}
|
2023-10-30 18:11:39 +00:00
|
|
|
{{- else }}
|
|
|
|
{{- partial "toc.html" . }}
|
|
|
|
{{- end }}
|