{{ define "title" }} {{ .Params.Title | default (T .Data.Plural) | default .Data.Plural | dict "Some" | T "AllSome" }} - {{ .Site.Title }} {{ end }} {{ define "main_inner_class" }}{{.Data.Plural}} posts-expand{{ end }} {{ define "main" }}

{{ if eq .Data.Plural "categories" }} {{ T "CateTitle" }} {{ else if eq .Data.Plural "tags" }} {{ T "TagTitle" }} {{ end }}

{{ if eq .Data.Plural "categories" }}
{{ T "Terms.categories" (.Scratch.Get "catsCount") | safeHTML }}
    {{ $allSecondaryCats := slice }} {{ range .Site.Taxonomies.categories.ByCount }} {{/* Rollback the change of the primary category name. & it could not support the lowercase category name. {{ $primaryCategory := .Name }} */}} {{ $primaryCategory := .Page.Title }} {{ $primaryCount := 0 }} {{ $secondaryCategories := slice }} {{ $pages := $.Scratch.Get "pages" }} {{ range where $pages "Params.categories" "intersect" (slice $primaryCategory) }} {{ if eq (index .Params.categories 0) $primaryCategory }} {{ $primaryCount = add $primaryCount 1 }} {{/** if and (isset .Params.categories 1) (not (in $secondaryCategories (index .Params.categories 1))) **/}} {{ if isset .Params.categories 1 }} {{ if not (in $secondaryCategories (index .Params.categories 1)) }} {{ $secondaryCategories = $secondaryCategories | append (index .Params.categories 1) }} {{ $allSecondaryCats = $allSecondaryCats | append (index .Params.categories 1) }} {{ end }} {{ end }} {{ end }} {{ end }} {{ if not (in $allSecondaryCats $primaryCategory) }}
  • {{ $primaryCategory }} {{ $primaryCount }}
    • {{ range $secondaryCategories }} {{ $secondaryCategory := . }} {{ $secondaryCount := 0 }} {{ range where $pages "Params.categories" "intersect" (slice $secondaryCategory) }} {{ if and (eq (index .Params.categories 0) $primaryCategory) (eq (index .Params.categories 1) $secondaryCategory) }} {{ $secondaryCount = add $secondaryCount 1 }} {{ end }} {{ end }}
    • {{ . }} {{ $secondaryCount }}
    • {{ end }}
    {{ end }} {{ end }}
{{ end }} {{ if eq .Data.Plural "tags" }} {{ $tags := .Site.Taxonomies.tags }}
{{ T "Terms.tags" (.Scratch.Get "tagsCount") | safeHTML }}
{{ $randNums := (seq 10) }} {{- range $name, $items := $tags }} {{ .Page.Title }} ({{ len $items }}) {{ end }}
{{ end }}
{{ end }}