diff --git a/hugo.toml b/hugo.toml index d0c9b5ec..62755b56 100644 --- a/hugo.toml +++ b/hugo.toml @@ -1205,6 +1205,17 @@ folderSlash = false # list of file or folder names to ignore ignoreList = [] +# FixIt 1.0.0 | NEW Taxonomy icons config +# Works with [taxonomies]. Configure [taxonomies] first, otherwise taxonomy icons will not take effect. +[params.taxonomy_icons] +# syntax: = [, <card icon>, <term title icon>] +# example: +# topic = [ +# "fa-solid fa-book-bookmark", +# "fa-solid fa-book", +# "fa-solid fa-book-open" +# ] + # FixIt 0.4.5 | NEW Print config [params.print] # whether to expand all admonitions before printing diff --git a/layouts/_partials/function/get-taxonomy-icon.html b/layouts/_partials/function/get-taxonomy-icon.html new file mode 100644 index 00000000..386ee79c --- /dev/null +++ b/layouts/_partials/function/get-taxonomy-icon.html @@ -0,0 +1,24 @@ +{{- /* + Resolve taxonomy icon by slot with site-level overrides. + + @param {String} .Taxonomy taxonomy singular key, e.g. "tag", "category" + @param {String} .Slot icon slot: "title", "card", "term" + @return {String} icon class +*/ -}} +{{- $taxonomy := .Taxonomy | default "category" -}} +{{- $slot := .Slot | default "title" -}} +{{- $defaults := dict + "tag" (slice "fa-solid fa-tags" "fa-solid fa-tag" "fa-solid fa-tag") + "category" (slice "fa-solid fa-folder-tree" "fa-regular fa-folder" "fa-regular fa-folder-open") + "collection" (slice "fa-solid fa-layer-group" "fa-solid fa-layer-group" "fa-solid fa-layer-group") +-}} +{{- $fallback := index $defaults "category" -}} +{{- $icons := index $defaults $taxonomy | default $fallback -}} +{{- with index site.Params "taxonomy_icons" -}} + {{- with index . $taxonomy -}} + {{- $icons = . | default $icons -}} + {{- end -}} +{{- end -}} +{{- $slotIndex := index (dict "title" 0 "card" 1 "term" 2) $slot | default 0 -}} +{{- $icon := index $icons $slotIndex | default (index $fallback $slotIndex) -}} +{{- return $icon -}} diff --git a/layouts/taxonomies.html b/layouts/taxonomies.html index e8c06344..d1b40033 100644 --- a/layouts/taxonomies.html +++ b/layouts/taxonomies.html @@ -1,9 +1,5 @@ {{- /* Taxonomies Page */ -}} -{{- $iconMap := dict - "category" "fa-regular fa-folder" - "collection" "fa-solid fa-layer-group" --}} -{{- $icon := index $iconMap .Data.Singular | default $iconMap.category -}} +{{- $icon := .Params.cardIcon | default (dict "Taxonomy" .Data.Singular "Slot" "card" | partial "function/get-taxonomy-icon.html") -}} <div class="taxonomy-cards {{ .Data.Plural }}"> {{- range .Data.Terms.ByCount -}} diff --git a/layouts/taxonomy.html b/layouts/taxonomy.html index fe82406f..f8d7410f 100644 --- a/layouts/taxonomy.html +++ b/layouts/taxonomy.html @@ -5,12 +5,7 @@ {{- define "content" -}} {{- $taxonomies := .Data.Plural -}} - {{- $iconMap := dict - "categories" "fa-solid fa-folder-tree" - "collections" "fa-solid fa-layer-group" - "tags" "fa-solid fa-tags" - -}} - {{- $icon := index $iconMap $taxonomies | default $iconMap.categories -}} + {{- $icon := .Params.titleIcon | default (dict "Taxonomy" .Data.Singular "Slot" "title" | partial "function/get-taxonomy-icon.html") -}} <div class="page archive"> {{- /* Title */ -}} diff --git a/layouts/term.html b/layouts/term.html index a25bd7e6..6c19f982 100644 --- a/layouts/term.html +++ b/layouts/term.html @@ -8,17 +8,8 @@ {{- /* Title */ -}} {{- $taxonomy := .Data.Singular -}} {{- $pageCount := len .Pages -}} - {{- $termIcon := "" -}} + {{- $termIcon := .Params.titleIcon | default (dict "Taxonomy" $taxonomy "Slot" "term" | partial "function/get-taxonomy-icon.html") -}} {{- $termTitle := .Title -}} - {{- if eq $taxonomy "category" -}} - {{- $termIcon = "fa-regular fa-folder-open" -}} - {{- else if eq $taxonomy "tag" -}} - {{- $termIcon = "fa-solid fa-tag" -}} - {{- else if eq $taxonomy "collection" -}} - {{- $termIcon = "fa-solid fa-layer-group" -}} - {{- else -}} - {{- $termTitle = printf "%v - %v" (T $taxonomy | default $taxonomy) .Title -}} - {{- end -}} <h1 class="single-title animate__animated animate__pulse animate__faster"> {{- with $termIcon -}} {{- dict "Class" (add . " me-1") | partial "plugin/icon.html" -}}