🎉 Feat: add taxonomy collections

This commit is contained in:
Cell
2023-12-06 11:26:08 +08:00
parent 8ccf57862c
commit c7a03ea847
16 changed files with 140 additions and 15 deletions
+11
View File
@@ -991,3 +991,14 @@ enableEmoji = true
section = ["HTML", "RSS"]
taxonomy = ["HTML"]
term = ["HTML", "RSS"]
# -------------------------------------------------------------------------------------
# Taxonomies Configuration
# See: https://gohugo.io/content-management/taxonomies/#configure-taxonomies
# -------------------------------------------------------------------------------------
[taxonomies]
# series = "series"
category = "categories"
tag = "tags"
collections = "collections"
+6
View File
@@ -29,6 +29,12 @@ other = "Kategorie"
[categories]
other = "Kategorien"
[collection]
other = ""
[collections]
other = ""
[tag]
other = "Tag"
+10 -4
View File
@@ -27,6 +27,12 @@ other = "Category"
[categories]
other = "Categories"
[collection]
other = "Collection"
[collections]
other = "Collections"
[tag]
other = "Tag"
@@ -96,10 +102,10 @@ other = "Share on"
# === posts/single.html ===
[single]
contents= "Contents"
repost= "Repost"
publishedOnDate= "published on {{ .Date }}"
includedInCategories= "included in {{ .Categories }}"
contents = "Contents"
repost = "Repost"
publishedOnDate = "published on {{ .Date }}"
includedInCategories = "included in {{ .Categories }}"
views = "views"
comments = "comments"
author = "Author"
+6
View File
@@ -29,6 +29,12 @@ other = "Categoría"
[categories]
other = "Categorías"
[collection]
other = ""
[collections]
other = ""
[tag]
other = "Etiqueta"
+6
View File
@@ -28,6 +28,12 @@ other = "Catégorie"
[categories]
other = "Catégories"
[collection]
other = ""
[collections]
other = ""
[tag]
other = "Tag"
+6
View File
@@ -29,6 +29,12 @@ other = "Categoria"
[categories]
other = "Categorie"
[collection]
other = ""
[collections]
other = ""
[tag]
other = "Etichetta"
+6
View File
@@ -29,6 +29,12 @@ other = "Kategoria"
[categories]
other = "Kategorie"
[collection]
other = ""
[collections]
other = ""
[tag]
other = "Tag"
+6
View File
@@ -29,6 +29,12 @@ other = "Categoria"
[categories]
other = "Categorias"
[collection]
other = ""
[collections]
other = ""
[tag]
other = "Tag"
+6
View File
@@ -29,6 +29,12 @@ other = "Categorie"
[categories]
other = "Categorii"
[collection]
other = ""
[collections]
other = ""
[tag]
other = "Etichetă"
+6
View File
@@ -29,6 +29,12 @@ other = "Категория"
[categories]
other = "Категории"
[collection]
other = ""
[collections]
other = ""
[tag]
other = "Тэг"
+6
View File
@@ -29,6 +29,12 @@ other = "Категорија"
[categories]
other = "Категорије"
[collection]
other = ""
[collections]
other = ""
[tag]
other = "Таг"
+6
View File
@@ -28,6 +28,12 @@ other = "Danh mục"
[categories]
other = "Danh mục"
[collection]
other = ""
[collections]
other = ""
[tag]
other = "Nhãn"
+6
View File
@@ -28,6 +28,12 @@ other = "分类"
[categories]
other = "分类"
[collection]
other = "合集"
[collections]
other = "合集"
[tag]
other = "标签"
+6
View File
@@ -28,6 +28,12 @@ other = "分類"
[categories]
other = "分類"
[collection]
other = "合集"
[collections]
other = "合集"
[tag]
other = "標籤"
+17 -11
View File
@@ -5,18 +5,24 @@
{{- define "content" -}}
<div class="page archive">
{{- /* Title */ -}}
{{- $taxonomy := .Data.Singular -}}
{{- $pageCount := len .Pages -}}
{{- $termIcon := "" -}}
{{- $termTitle := .Title -}}
{{- if eq $taxonomy "category" -}}
{{- $termIcon = "fa-regular fa-folder-open fa-fw" -}}
{{- else if eq $taxonomy "tag" -}}
{{- $termIcon = "fa-solid fa-tag fa-fw" -}}
{{- else if eq $taxonomy "collections" -}}
{{- $termIcon = "fa-solid fa-layer-group fa-fw" -}}
{{- else -}}
{{- $termTitle = printf "%v - %v" (T $taxonomy | default $taxonomy) .Title -}}
{{- end -}}
<h2 class="single-title animate__animated animate__pulse animate__faster">
{{- $taxonomy := .Data.Singular -}}
{{- $pageCount := len .Pages -}}
{{- if eq $taxonomy "category" -}}
{{ dict "Class" "fa-regular fa-folder-open fa-fw" | partial "plugin/icon.html" }}
{{ .Title }}&nbsp;<sup>{{- $pageCount -}}</sup>
{{- else if eq $taxonomy "tag" -}}
{{ dict "Class" "fa-solid fa-tag fa-fw" | partial "plugin/icon.html" }}
{{ .Title }}&nbsp;<sup>{{- $pageCount -}}</sup>
{{- else -}}
{{- printf "%v - %v" (T $taxonomy | default $taxonomy) .Title -}}
{{- end -}}
{{- with $termIcon -}}
{{- dict "Class" . | partial "plugin/icon.html" }}
{{ end -}}
{{ $termTitle }}&nbsp;<sup>{{- $pageCount -}}</sup>
</h2>
{{- /* Paginate */ -}}
+30
View File
@@ -0,0 +1,30 @@
{{- /* Collections Page */ -}}
<div class="categories-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">
<h3 class="card-item-title">
<a href='{{ partial "function/escapeurl.html" .RelPermalink }}'>
{{ dict "Class" "fa-solid fa-layer-group fa-fw" | partial "plugin/icon.html" }}
{{ .Page.Title }}&nbsp;<sup>{{- len $pages -}}</sup>
</a>
</h3>
{{- range first 5 $pages -}}
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">{{- .Title -}}</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>