♻️ Refactor: taxonomy templates lookup order

This commit is contained in:
Cell
2025-04-27 15:26:52 +08:00
parent 78971cdedb
commit f7a9c52aac
6 changed files with 22 additions and 57 deletions
+1 -2
View File
@@ -109,8 +109,7 @@
}
.page {
.categories-card,
.collections-card {
.taxonomy-cards {
.card-item {
width: 100%;
}
+1 -2
View File
@@ -1,5 +1,4 @@
.categories-card,
.collections-card {
.taxonomy-cards {
margin: 0 auto;
display: flex;
align-items: flex-start;
-36
View File
@@ -1,36 +0,0 @@
{{- /* Collections Page */ -}}
<div class="collections-card">
{{- range .Data.Terms.ByCount -}}
{{- $term := .Term -}}
{{- $pages := .Pages -}}
{{- with $.Site.GetPage "taxonomy" (printf "%v/%v" $.Type $term) -}}
<div class="card-item">
<div class="card-item-wrapper">
<h2 class="card-item-title">
<a href='{{ partial "function/escapeurl.html" .RelPermalink }}'>
{{- dict "Class" "fa-solid fa-layer-group fa-fw me-1" | partial "plugin/icon.html" -}}
{{- .Page.Title }} <sup>{{ len $pages }}</sup>
</a>
</h2>
{{- range first 5 $pages -}}
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">
{{- $repost := .Params.repost | default dict -}}
{{- if eq $repost.enable true -}}
{{- dict "Class" "fa-solid fa-share fa-fw text-success me-1" | partial "plugin/icon.html" -}}
{{- end -}}
{{- cond (.Param "capitalizeTitles") (title .LinkTitle) .LinkTitle -}}
</a>
</article>
{{- end -}}
{{- if gt (len $pages) 5 -}}
<span class="more-post">
<a href='{{ partial "function/escapeurl.html" .RelPermalink }}' class="more-single-link">{{ T "pagination.more" }} >></a>
</span>
{{- end -}}
</div>
</div>
{{- end -}}
{{- end -}}
</div>
@@ -1,6 +1,11 @@
{{- /* Categories Page */ -}}
{{- /* Taxonomies Page */ -}}
{{- $iconMap := dict
"category" "fa-regular fa-folder"
"collection" "fa-solid fa-layer-group"
-}}
{{- $icon := index $iconMap .Data.Singular | default $iconMap.category -}}
<div class="categories-card">
<div class="taxonomy-cards {{ .Data.Plural }}">
{{- range .Data.Terms.ByCount -}}
{{- $term := .Term -}}
{{- $pages := .Pages -}}
@@ -9,7 +14,7 @@
<div class="card-item-wrapper">
<h2 class="card-item-title">
<a href='{{ partial "function/escapeurl.html" .RelPermalink }}'>
{{- dict "Class" "fa-regular fa-folder fa-fw me-1" | partial "plugin/icon.html" -}}
{{- dict "Class" (add $icon " fa-fw me-1") | partial "plugin/icon.html" -}}
{{- .Page.Title }} <sup>{{ len $pages }}</sup>
</a>
</h2>
@@ -34,3 +39,4 @@
{{- end -}}
{{- end -}}
</div>
{{- /* EOF */ -}}
+10 -13
View File
@@ -5,24 +5,21 @@
{{- 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 -}}
<div class="page archive">
{{- $termsIcon := "" -}}
{{- if eq $taxonomies "categories" -}}
{{- $termsIcon = "fa-solid fa-folder-tree" -}}
{{- else if eq $taxonomies "tags" -}}
{{- $termsIcon = "fa-solid fa-tags" -}}
{{- else if eq $taxonomies "collections" -}}
{{- $termsIcon = "fa-solid fa-layer-group" -}}
{{- end -}}
{{- /* Title */ -}}
<h1 class="single-title animate__animated animate__pulse animate__faster">
{{- with $termsIcon -}}
{{- dict "Class" (add . " fa-fw me-1") | partial "plugin/icon.html" -}}
{{- end -}}
{{- dict "Class" (add $icon " fa-fw me-1") | partial "plugin/icon.html" -}}
{{- .Params.Title | default (T $taxonomies) | default $taxonomies | dict "Some" | T "allSome" }} <sup>{{ len .Data.Terms.ByCount }}</sup>
</h1>
{{- /* Render miscellaneous terms */ -}}
{{- .Render $taxonomies -}}
{{- /* Render different taxonomies */ -}}
{{- $template := cond ( eq $taxonomies "tags") "tags" "taxonomies" -}}
{{- .Render $template -}}
</div>
{{- end -}}
+1 -1
View File
@@ -1,4 +1,4 @@
{{- .Scratch.Set "version" "v0.3.20-d41e53bb" -}}
{{- .Scratch.Set "version" "v0.3.20-ee39fed6" -}}
{{- .Scratch.Set "this" dict -}}
{{- partial "init/detection-env.html" . -}}