{{ if $.Site.Params.hierarchicalCategories }}
{{ $.Scratch.Set "max-level" 0 }}
{{ range where $.Site.RegularPages "Type" "posts" }}
{{ $page := . }}
{{ if .Params.categories }}
{{ $categories := (apply .Params.categories "urlize" ".") }}
{{ range $index,$value := .Params.categories }}
{{ if gt $index ($.Scratch.Get "max-level") }}
{{ $.Scratch.Set "max-level" $index }}
{{ end }}
{{ $path := (printf "%s" (delimit (first (add $index 1) $categories) " ")) }}
{{ $name := (printf "%s-%d" ($value | urlize) $index) }}
{{ $level := (printf "categories-level-%d" $index) }}
{{ if $.Scratch.Get $name }}
{{ $category := ($.Scratch.Get $name) }}
{{ if and (not (in $category.parent ($.Scratch.Get "parent"))) (gt $index 0) }}
{{ $node := (dict "path" $path "name" $category.name "parents" (split (printf "%s,%s" (delimit $category.parents ",") ($.Scratch.Get "parent")) ",")) }}
{{ $.Scratch.Set $path $node }}
{{ $.Scratch.SetInMap $level $path $node }}
{{ end }}
{{ else }}
{{ $node := (dict "path" $path "name" $value "parents" (split ($.Scratch.Get "parent") ",")) }}
{{ $.Scratch.Set $name $node }}
{{ $.Scratch.SetInMap $level $path $node }}
{{ end }}
{{ $.Scratch.SetInMap (printf "%s" (delimit (first (add $index 1) $categories) "/")) $page.File.UniqueID $page }}
{{ $.Scratch.Set "parent" $path }}
{{ end }}
{{ $.Scratch.Set "parent" nil }}
{{ end }}
{{ end }}
{{ end }}
{{ partial "head.html" . }}
{{ partial "header.html" . }}
{{ partial "sidebar.html" . }}
{{ partial "post/header-cover.html" . }}
{{ if $.Site.Params.hierarchicalCategories }}
{{ range $.Scratch.GetSortedMapValues "categories-level-0" }}
{{ $path := .path }}
{{ .name }}
{{ range seq ($.Scratch.Get "max-level") }}
{{ $index := . }}
{{ range $.Scratch.GetSortedMapValues (printf "categories-level-%d" $index) }}
{{ partial "internal/recursive-categories-1.html" (dict "scratch" $.Scratch "category" . "level" $index "parent" $path) }}
{{ end }}
{{ end }}
{{ end }}
{{ else }}
{{ range .Data.Terms.ByCount }}
{{ end }}
{{ end }}
{{ if $.Site.Params.hierarchicalCategories }}
{{ range $.Scratch.GetSortedMapValues "categories-level-0" }}
{{ $path := .path }}
{{ range ($.Scratch.GetSortedMapValues $path) }}
-
{{ .Title }} - {{ partial "internal/date" . }}
{{ end }}
{{ range seq ($.Scratch.Get "max-level") }}
{{ $index := . }}
{{ range $.Scratch.GetSortedMapValues (printf "categories-level-%d" $index) }}
{{ partial "internal/recursive-categories-full-1.html" (dict "scratch" $.Scratch "category" . "level" $index "parent" $path) }}
{{ end }}
{{ end }}
{{ end }}
{{ else }}
{{ range .Data.Terms.ByCount }}
{{ range .Pages.ByDate }}
-
{{ .Title }}
- {{ partial "internal/date" . }}
{{ end }}
{{ end }}
{{ end }}
{{ partial "footer.html" . }}
{{ partial "about.html" . }}
{{ partial "cover.html" . }}
{{ partial "script.html" . }}