diff options
| author | eltrac <hi@eltr.ac> | 2026-02-15 10:21:42 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-02-15 10:21:42 +0800 |
| commit | 9a9de3cb078d77409af895c74e145ec999e2bd90 (patch) | |
| tree | 4e4aac938bb989b38507cd869b48d10b6275707a | |
| parent | 5ecd478ad28db83d409b45f8d15c36567b372c89 (diff) | |
refactor: reduce all-tags partial
| -rw-r--r-- | layouts/_partials/taxonomy/all-tags.html | 46 | ||||
| -rw-r--r-- | layouts/tags/taxonomy.html | 47 |
2 files changed, 46 insertions, 47 deletions
diff --git a/layouts/_partials/taxonomy/all-tags.html b/layouts/_partials/taxonomy/all-tags.html deleted file mode 100644 index efd63fb4..00000000 --- a/layouts/_partials/taxonomy/all-tags.html +++ /dev/null @@ -1,46 +0,0 @@ -<!-- Display Tags --> -<section> - {{ $categorizedTags := dict }} - {{ $uncategorizedTags := slice }} - - <!-- Group tags by category --> - {{ range $tagName, $tagPages := .Site.Taxonomies.tags }} - {{ $tagPage := site.GetPage (printf "/tags/%s" $tagName) }} - {{ $tagData := dict "Name" $tagName "Count" (len $tagPages) "Page" $tagPage }} - {{ if $tagPage.Params.category }} - {{ $category := $tagPage.Params.category }} - {{ $categoryTags := index $categorizedTags $category | default slice }} - {{ $categoryTags = $categoryTags | append $tagData }} - {{ $categorizedTags = merge $categorizedTags (dict $category $categoryTags) }} - {{ else }} - {{ $uncategorizedTags = $uncategorizedTags | append $tagData }} - {{ end }} - {{ end }} - - <!-- Sort tags by count --> - {{ $uncategorizedTags = sort $uncategorizedTags "Count" "desc" }} - {{ range $category, $categoryTags := $categorizedTags }} - {{ $categorizedTags = merge $categorizedTags (dict $category (sort $categoryTags "Count" "desc")) }} - {{ end }} - - <!-- Display uncategorized tags first --> - {{ if $uncategorizedTags }} - <div class="flex flex-wrap gap-2"> - {{ range $uncategorizedTags }} - {{ partial "taxonomy/tag-pill" . }} - {{ end }} - </div> - {{ end }} - - <!-- Display categorized tags --> - {{ range $category, $categoryTags := $categorizedTags }} - <div> - <h3>{{ $category }}</h3> - <div class="flex flex-wrap gap-2"> - {{ range $categoryTags }} - {{ partial "taxonomy/tag-pill" . }} - {{ end }} - </div> - </div> - {{ end }} -</section> diff --git a/layouts/tags/taxonomy.html b/layouts/tags/taxonomy.html index 4a6a2d6e..633e9c09 100644 --- a/layouts/tags/taxonomy.html +++ b/layouts/tags/taxonomy.html @@ -1,6 +1,51 @@ {{ define "main" }} <article> {{ partial "header" . }} - {{ partial "taxonomy/all-tags.html" . }} + <!-- Display Tags --> + <section> + {{ $categorizedTags := dict }} + {{ $uncategorizedTags := slice }} + + <!-- Group tags by category --> + {{ range $tagName, $tagPages := .Site.Taxonomies.tags }} + {{ $tagPage := site.GetPage (printf "/tags/%s" $tagName) }} + {{ $tagData := dict "Name" $tagName "Count" (len $tagPages) "Page" $tagPage }} + {{ if $tagPage.Params.category }} + {{ $category := $tagPage.Params.category }} + {{ $categoryTags := index $categorizedTags $category | default slice }} + {{ $categoryTags = $categoryTags | append $tagData }} + {{ $categorizedTags = merge $categorizedTags (dict $category $categoryTags) }} + {{ else }} + {{ $uncategorizedTags = $uncategorizedTags | append $tagData }} + {{ end }} + {{ end }} + + <!-- Sort tags by count --> + {{ $uncategorizedTags = sort $uncategorizedTags "Count" "desc" }} + {{ range $category, $categoryTags := $categorizedTags }} + {{ $categorizedTags = merge $categorizedTags (dict $category (sort $categoryTags "Count" "desc")) }} + {{ end }} + + <!-- Display uncategorized tags first --> + {{ if $uncategorizedTags }} + <div class="flex flex-wrap gap-2"> + {{ range $uncategorizedTags }} + {{ partial "taxonomy/tag-pill" . }} + {{ end }} + </div> + {{ end }} + + <!-- Display categorized tags --> + {{ range $category, $categoryTags := $categorizedTags }} + <div> + <h3>{{ $category }}</h3> + <div class="flex flex-wrap gap-2"> + {{ range $categoryTags }} + {{ partial "taxonomy/tag-pill" . }} + {{ end }} + </div> + </div> + {{ end }} + </section> {{ partial "footer.html" . }} {{ end }} |
