{{- if or (eq .Kind "taxonomy") (eq .Kind "term") }} {{- $lastCapital := "" }} {{- $pages := slice }} {{- if eq .Kind "taxonomy" }} {{- range .Data.Terms }} {{- $len := 0 }} {{- range .Pages }} {{- $c:=""}}{{/* count pages of term */}} {{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableTagHiddenPages true) ) }} {{- $len = add $len 1 }} {{- end }} {{- end }} {{- if $len }} {{- $pages = $pages| append (dict "Title" (default (humanize .Page.Data.Term | strings.Title) .Page.Title) "Page" . "Len" $len )}} {{- end }} {{- end }} {{- else if eq .Kind "term" }} {{- range .Pages }} {{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableTagHiddenPages true) ) }} {{- $pages = $pages | append (dict "Title" .Title "Page" . )}} {{- end }} {{- end }} {{- end }} {{- $toc_pages := "" }} {{- range sort $pages ".Title" }} {{- $capital := substr .Title 0 1 | upper }} {{- if ne $lastCapital $capital }} {{- $toc_pages = printf "%s
  • %s
  • \n" $toc_pages ($capital | plainify | anchorize) $capital }} {{- end }} {{- $lastCapital = $capital }} {{- end }} {{- $toc := trim (partial "toc.html" .) " \n\r\t" }} {{- if and (not $toc) $toc_pages }} {{- $toc = printf "" }} {{- end }} {{- if and $toc $toc_pages }} {{- $toc = replaceRE "^()$" " ${1}" $toc }} {{- $toc = replaceRE "([ \\t]*[\\s]*)$" (printf "%s${1}" $toc_pages) $toc }} {{- end }} {{ $toc | safeHTML }} {{- else }} {{- partial "toc.html" . }} {{- end }}