Skip to content

Commit

Permalink
feat: add the taxonomicOrder parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Jan 9, 2022
1 parent 074baf5 commit e3220a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ googleAdsense = ""
taxonomyPostCount = 20 # The number of taxonomy's posts. Turn off by setting it to false.
countTaxonomyPosts = true # Count posts of taxonomy.

# taxonomicOrder = ["categories", "tags", "series"] # The order of taxonomies on the sidebar.

# pinnedPost = false # Turn on/off pinned posts.
pinnedPostCount = 3 # The number of pinned posts.

Expand Down
12 changes: 11 additions & 1 deletion layouts/partials/sidebar/taxonomies.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{{- range $key, $value := .Site.Taxonomies -}}
{{- $order := default (slice "series" "categories" "tags") $.Site.Params.taxonomicOrder -}}
{{- range $key, $value := $.Site.Taxonomies -}}
{{- if not (in $order $key) -}}
{{- $order = $order | append $key -}}
{{- end -}}
{{- end -}}
{{- range $expected := $order -}}
{{- range $key, $value := $.Site.Taxonomies -}}
{{- if eq $key $expected -}}
{{- $countPosts := default false $.Site.Params.countTaxonomyPosts -}}
{{- $countParams := dict "categories" "categoryCount" "tags" "tagCount" "series" "seriesCount" -}}
{{- $param := default "" (index $countParams $key) -}}
Expand Down Expand Up @@ -28,4 +36,6 @@ <h2 class="card-title">
</section>
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

0 comments on commit e3220a8

Please sign in to comment.