mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
feat(taxonomy): support taxonomy_icons with shared icon resolver and front matter icon overrides (#732)
- Added new config section: `params.taxonomy_icons` - Syntax: `<taxonomy> = [<title icon>, <card icon>, <term title icon>]` - Added a shared resolver partial to centralize taxonomy icon lookup. - Updated taxonomy-related templates to use the shared resolver instead of hardcoded icon maps. - Added front matter overrides for taxonomy pages: - `titleIcon` - `cardIcon` (only for taxonomy `_index.md`) Icon resolving priority now is: 1. Front matter override (`titleIcon` / `cardIcon`) 2. `params.taxonomy_icons` custom config 3. Built-in defaults (`tag`, `category`, `collection`)
This commit is contained in:
@@ -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 -}}
|
||||
Reference in New Issue
Block a user