diff options
| -rw-r--r-- | content/tags/写作快闪ß/_index.md | 4 | ||||
| -rw-r--r-- | content/tags/每日写作计划α/_index.md | 4 | ||||
| -rw-r--r-- | layouts/_default/taxonomy.html | 86 |
3 files changed, 78 insertions, 16 deletions
diff --git a/content/tags/写作快闪ß/_index.md b/content/tags/写作快闪ß/_index.md new file mode 100644 index 00000000..609f6632 --- /dev/null +++ b/content/tags/写作快闪ß/_index.md @@ -0,0 +1,4 @@ +--- +title: 写作快闪ß +category: 归档 +--- diff --git a/content/tags/每日写作计划α/_index.md b/content/tags/每日写作计划α/_index.md new file mode 100644 index 00000000..5e066b41 --- /dev/null +++ b/content/tags/每日写作计划α/_index.md @@ -0,0 +1,4 @@ +--- +title: 每日写作计划α +category: 归档 +--- diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html index e27d41a8..ef8f515f 100644 --- a/layouts/_default/taxonomy.html +++ b/layouts/_default/taxonomy.html @@ -5,23 +5,77 @@ <!-- Display Tags --> <section class="taxonomy-tags"> - {{ range sort .Site.Taxonomies.tags "Count" "desc" }} - <a href="{{ .Page.RelPermalink }}" - class="taxonomy-tags-item{{ if lt .Count 4 }} dimmed{{ end }}"> - {{ if .Page.Params.icon }} - {{ if or (hasPrefix .Page.Params.icon "http://") (hasPrefix .Page.Params.icon "https://") }} - <span class="tag-icon"> - <img src="{{ .Page.Params.icon }}" alt="{{ .Page.LinkTitle }}" - style="height:1em;width:1em"> - </span> - {{ else }} - <span class="tag-icon">{{ .Page.Params.icon }}</span> - {{ end }} - {{ end }} - <span class="tag-name">{{ if not .Page.Params.icon }}#{{ end }}{{ .Page.LinkTitle }}</span> - <span class="tag-count">{{ .Count }}</span> - </a> + {{ $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="taxonomy-tags"> + {{ range $uncategorizedTags }} + <a href="{{ .Page.RelPermalink }}" + class="taxonomy-tags-item{{ if lt .Count 4 }} dimmed{{ end }}"> + {{ if .Page.Params.icon }} + {{ if or (hasPrefix .Page.Params.icon "http://") (hasPrefix .Page.Params.icon "https://") }} + <span class="tag-icon"> + <img src="{{ .Page.Params.icon }}" alt="{{ .Page.LinkTitle }}" + style="height:1em;width:1em"> + </span> + {{ else }} + <span class="tag-icon">{{ .Page.Params.icon }}</span> + {{ end }} + {{ end }} + <span class="tag-name">{{ if not .Page.Params.icon }}#{{ end }}{{ .Page.LinkTitle }}</span> + <span class="tag-count">{{ .Count }}</span> + </a> + {{ end }} + </div> + {{ end }} + + <!-- Display categorized tags --> + {{ range $category, $categoryTags := $categorizedTags }} + <div class="taxonomy-category"> + <h3 class="taxonomy-category-title">{{ $category }}</h3> + <div class="taxonomy-tags"> + {{ range $categoryTags }} + <a href="{{ .Page.RelPermalink }}" + class="taxonomy-tags-item{{ if lt .Count 4 }} dimmed{{ end }}"> + {{ if .Page.Params.icon }} + {{ if or (hasPrefix .Page.Params.icon "http://") (hasPrefix .Page.Params.icon "https://") }} + <span class="tag-icon"> + <img src="{{ .Page.Params.icon }}" alt="{{ .Page.LinkTitle }}" + style="height:1em;width:1em"> + </span> + {{ else }} + <span class="tag-icon">{{ .Page.Params.icon }}</span> + {{ end }} + {{ end }} + <span class="tag-name">{{ if not .Page.Params.icon }}#{{ end }}{{ .Page.LinkTitle }}</span> + <span class="tag-count">{{ .Count }}</span> + </a> + {{ end }} + </div> + </div> + {{ end }} </section> </article> {{ partial "footer.html" . }} |
