From 9a9de3cb078d77409af895c74e145ec999e2bd90 Mon Sep 17 00:00:00 2001 From: eltrac Date: Sun, 15 Feb 2026 10:21:42 +0800 Subject: refactor: reduce all-tags partial --- layouts/_partials/taxonomy/all-tags.html | 46 ------------------------------- layouts/tags/taxonomy.html | 47 +++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 47 deletions(-) delete mode 100644 layouts/_partials/taxonomy/all-tags.html 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 @@ - -
- {{ $categorizedTags := dict }} - {{ $uncategorizedTags := slice }} - - - {{ 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 }} - - - {{ $uncategorizedTags = sort $uncategorizedTags "Count" "desc" }} - {{ range $category, $categoryTags := $categorizedTags }} - {{ $categorizedTags = merge $categorizedTags (dict $category (sort $categoryTags "Count" "desc")) }} - {{ end }} - - - {{ if $uncategorizedTags }} -
- {{ range $uncategorizedTags }} - {{ partial "taxonomy/tag-pill" . }} - {{ end }} -
- {{ end }} - - - {{ range $category, $categoryTags := $categorizedTags }} -
-

{{ $category }}

-
- {{ range $categoryTags }} - {{ partial "taxonomy/tag-pill" . }} - {{ end }} -
-
- {{ end }} -
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" }}
{{ partial "header" . }} - {{ partial "taxonomy/all-tags.html" . }} + +
+ {{ $categorizedTags := dict }} + {{ $uncategorizedTags := slice }} + + + {{ 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 }} + + + {{ $uncategorizedTags = sort $uncategorizedTags "Count" "desc" }} + {{ range $category, $categoryTags := $categorizedTags }} + {{ $categorizedTags = merge $categorizedTags (dict $category (sort $categoryTags "Count" "desc")) }} + {{ end }} + + + {{ if $uncategorizedTags }} +
+ {{ range $uncategorizedTags }} + {{ partial "taxonomy/tag-pill" . }} + {{ end }} +
+ {{ end }} + + + {{ range $category, $categoryTags := $categorizedTags }} +
+

{{ $category }}

+
+ {{ range $categoryTags }} + {{ partial "taxonomy/tag-pill" . }} + {{ end }} +
+
+ {{ end }} +
{{ partial "footer.html" . }} {{ end }} -- cgit v1.2.3