{{ if .Site.Params.displayListTitle }}

{{ .Title | default (.Type | title) }}

{{ end }}
{{ .Scratch.Delete "categories" }} {{ range $.Site.RegularPages }} {{ with .Param "categories" }} {{ $.Scratch.Delete "category" }} {{ range $index, $category := . }} {{ $category := (printf `/%s` ($category | urlize)) }} {{ $.Scratch.Add "category" $category }} {{ $.Scratch.Add "categories" (slice ($.Scratch.Get "category")) }} {{ end }} {{ end }} {{ end }} {{ $categories := uniq (.Scratch.Get "categories") | sort }}
    {{ range $index, $value := $categories }} {{ $categoryTerms := (split (strings.TrimPrefix "/" .) "/") }} {{ $depth := (len $categoryTerms) }} {{ $lastTerm := (delimit (last 1 $categoryTerms) " ") }} {{ $url := urls.Parse $lastTerm }} {{ $path := $url.Path }} {{ with $.Site.GetPage (printf `/categories/%s` $path) }} {{ $linkTarget := . }} {{ $depthPrev := 0 }} {{ if ge $index 1 }} {{ $categoryPrev := index $categories (sub $index 1) }} {{ $depthPrev = len (split (strings.TrimPrefix "/" $categoryPrev) "/") }} {{ end }} {{ $depthNext := 0 }} {{ if lt $index (sub (len $categories) 1) }} {{ $categoryNext := index $categories (add $index 1) }} {{ $depthNext = len (split (strings.TrimPrefix "/" $categoryNext) "/") }} {{ end }} {{ if or (le $depth $depthPrev) (eq $index 0) }}
  • {{ end }} {{ if and (gt $depth $depthPrev) (ne $index 0) }}
    • {{ end }} {{ .LinkTitle | default .Data.Term | default $path }} {{ if $.Site.Params.displayPostsCount }} {{ printf "(%d)" (len .Data.category) }} {{ end }} {{ if $.Site.Params.displayPosts }} {{ $.Scratch.Delete "pages" }} {{ range $.Site.RegularPages }} {{ $page := . }} {{ with .Param "categories" }} {{ $.Scratch.Delete "category" }} {{ range . }} {{ $category := (printf `/%s` (. | urlize)) }} {{ $.Scratch.Add "category" $category }} {{ end }} {{ $category := $.Scratch.Get "category" }} {{ if eq $value $category }} {{ $.Scratch.Add "pages" (slice $page) }} {{ end }} {{ end }} {{ end }} {{ $pages := $.Scratch.Get "pages" }} {{ partial "utils/limit-tree-posts.html" (dict "$" $ "pages" $pages "linkTarget" $linkTarget) }} {{ end }} {{ if and (gt $depth $depthNext) (ne $index (sub (len $categories) 1)) }} {{ range seq (sub $depth $depthNext) }} {{ if le . (sub $depth $depthNext) }}
    {{ end }} {{ end }} {{ end }} {{ if ge $depth $depthNext }}
  • {{ end }} {{ end }} {{ end }}