diff --git a/layouts/partials/hb/modules/blog/functions/filter-taxonomies.html b/layouts/partials/hb/modules/blog/functions/filter-taxonomies.html new file mode 100644 index 00000000..8061aa13 --- /dev/null +++ b/layouts/partials/hb/modules/blog/functions/filter-taxonomies.html @@ -0,0 +1,31 @@ +{{- $opts := . }} +{{- $defaultLimit := default 10 $opts.limit }} +{{- $defaultCount := default true $opts.count }} +{{- $taxonomies := slice }} +{{- range $name, $taxonomy := site.Taxonomies }} + {{- $limit := $defaultLimit }} + {{- $count := $defaultCount }} + {{- $weight := 10 }} + {{- with index $opts $name }} + {{- if default false .disable }} + {{- continue }} + {{- end }} + {{- with .limit }} + {{- $limit = . }} + {{- end }} + {{- if isset . "count" }} + {{- $count = .count }} + {{- end }} + {{- with .weight }} + {{- $weight = . }} + {{- end }} + {{- end }} + {{- $taxonomies = $taxonomies | append (dict + "name" $name + "terms" (first $limit $taxonomy.ByCount) + "count" $count + "weight" $weight) + }} +{{- end }} +{{- return sort $taxonomies "weight" }} + diff --git a/layouts/partials/hb/modules/blog/taxonomies/default.html b/layouts/partials/hb/modules/blog/taxonomies/default.html index 411e65de..fb4fcc65 100644 --- a/layouts/partials/hb/modules/blog/taxonomies/default.html +++ b/layouts/partials/hb/modules/blog/taxonomies/default.html @@ -1,26 +1,22 @@ -{{- $limit := default 10 .limit }} -{{- $count := default true .count }} -{{- range $name, $taxonomy := site.Taxonomies }} - {{- $idx := 0 }} +{{- $taxonomies := partial "hb/modules/blog/functions/filter-taxonomies" . }} +{{- range $taxonomies }} + {{- $name := .name }} + {{- $count := .count }}