refactor(widget): taxonomy widget (#763)

* Add link to navbar sections and refactor names

* Prevent duplicate tags and categories information

* Add style to the widget links

* refactor: add `taxonomy` widget

Replaces `categories` and `tag-cloud` widget.

* style: remove unused `font_size_{{ .Count }}` in `taxonomy` widget

---------

Co-authored-by: Jimmy Cai <hi@jimmycai.com>
This commit is contained in:
Jacob Zhong 2023-08-27 12:26:53 -04:00 committed by GitHub
parent 5063e8f0b8
commit 4be110e540
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 50 additions and 141 deletions

View File

@ -65,3 +65,11 @@
} }
} }
} }
/* Color for widget titles */
.widget-title a.widget-link {
color: var(--accent-color);
&:hover {
color: var(--accent-color-darker);
}
}

View File

@ -74,16 +74,20 @@ type = "archives"
limit = 5 limit = 5
[[widgets.homepage]] [[widgets.homepage]]
type = "categories" type = "taxonomy"
[widgets.homepage.params] [widgets.homepage.params]
limit = 10 limit = 10
type = "tags"
icon = "tag"
[[widgets.homepage]] [[widgets.homepage]]
type = "tag-cloud" type = "taxonomy"
[widgets.homepage.params] [widgets.homepage.params]
limit = 10 limit = 10
type = "categories"
icon = "categories"
[[widgets.page]] [[widgets.page]]
type = "toc" type = "toc"

View File

@ -29,12 +29,6 @@ widget:
title: الارشيفات title: الارشيفات
more: اكثر more: اكثر
tagCloud:
title: وسوم
categoriesCloud:
title: التصنيفات
search: search:
title: بحث title: بحث
placeholder: اكتب... placeholder: اكتب...

View File

@ -35,10 +35,6 @@ widget:
archives: archives:
title: আর্কাইভ title: আর্কাইভ
more: আরও more: আরও
tagCloud:
title: ট্যাগ
categoriesCloud:
title: বিভাগ
search: search:
title: অনুসন্ধান title: অনুসন্ধান

View File

@ -28,10 +28,6 @@ widget:
archives: archives:
title: Arxiu title: Arxiu
more: Més more: Més
tagCloud:
title: Etiquetes
categoriesCloud:
title: Categories
search: search:
title: Cerca title: Cerca

View File

@ -28,10 +28,6 @@ widget:
archives: archives:
title: Archiv title: Archiv
more: Weitere more: Weitere
tagCloud:
title: Schlagwörter
categoriesCloud:
title: Kategorien
search: search:
title: Suche title: Suche

View File

@ -28,8 +28,6 @@ widget:
archives: archives:
title: Αρχειο title: Αρχειο
more: Περισσότερα more: Περισσότερα
tagCloud:
title: Tags
search: search:
title: Αναζήτηση title: Αναζήτηση

View File

@ -31,10 +31,6 @@ widget:
archives: archives:
title: Archives title: Archives
more: More more: More
tagCloud:
title: Tags
categoriesCloud:
title: Categories
search: search:
title: Search title: Search

View File

@ -28,10 +28,6 @@ widget:
archives: archives:
title: Archivo title: Archivo
more: Más more: Más
tagCloud:
title: Etiquetas
categoriesCloud:
title: Categorías
search: search:
title: Búsqueda title: Búsqueda

View File

@ -28,10 +28,6 @@ widget:
archives: archives:
title: آرشیو title: آرشیو
more: بیشتر more: بیشتر
tagCloud:
title: تگ ها
categoriesCloud:
title: دسته بندی
search: search:
title: جستجو title: جستجو

View File

@ -28,8 +28,6 @@ widget:
archives: archives:
title: Archives title: Archives
more: Autres more: Autres
tagCloud:
title: Mots clés
search: search:
title: Rechercher title: Rechercher

View File

@ -28,10 +28,6 @@ widget:
archives: archives:
title: Archívum title: Archívum
more: Több more: Több
tagCloud:
title: Cimkék
categoriesCloud:
title: Kategóriák
search: search:
title: Keresés title: Keresés

View File

@ -28,10 +28,6 @@ widget:
archives: archives:
title: Arsip title: Arsip
more: Lebih more: Lebih
tagCloud:
title: Tag
categoriesCloud:
title: Kategori
search: search:
title: Cari title: Cari

View File

@ -28,10 +28,6 @@ widget:
archives: archives:
title: Archivi title: Archivi
more: Di più more: Di più
tagCloud:
title: Tags
categoriesCloud:
title: Categorie
search: search:
title: Cerca title: Cerca

View File

@ -17,10 +17,6 @@ widget:
archives: archives:
title: アーカイブ title: アーカイブ
more: さらに見る more: さらに見る
tagCloud:
title: タグ
categoriesCloud:
title: カテゴリ
search: search:
title: 検索 title: 検索

View File

@ -29,12 +29,6 @@ widget:
title: 보관함 title: 보관함
more: 더보기 more: 더보기
categoriesCloud:
title: 카테고리
tagCloud:
title: 태그
search: search:
title: 검색 title: 검색
placeholder: 검색어를 입력하세요... placeholder: 검색어를 입력하세요...

View File

@ -23,10 +23,6 @@ widget:
archives: archives:
title: Archief title: Archief
more: Meer more: Meer
tagCloud:
title: Tags
categoriesCloud:
title: Categorie
search: search:
title: Zoeken title: Zoeken

View File

@ -34,11 +34,6 @@ widget:
archives: archives:
title: Archiwum title: Archiwum
more: Więcej more: Więcej
tagCloud:
title: Tagi
categoriesCloud:
title: Kategorie
search: search:
title: Szukaj title: Szukaj

View File

@ -29,12 +29,6 @@ widget:
title: Arquivos title: Arquivos
more: Mais more: Mais
tagCloud:
title: Tags
categoriesCloud:
title: Categorias
search: search:
title: Busca title: Busca
placeholder: Digite algo... placeholder: Digite algo...

View File

@ -45,12 +45,6 @@ widget:
other: Arquivos other: Arquivos
more: more:
other: Mais other: Mais
tagCloud:
title:
other: Tags
categoriesCloud:
title:
other: Categorias
search: search:
title: title:

View File

@ -30,8 +30,6 @@ widget:
archives: archives:
title: Архивы title: Архивы
more: Ещё more: Ещё
tagCloud:
title: Теги
search: search:
title: Поиск title: Поиск

View File

@ -28,8 +28,6 @@ widget:
archives: archives:
title: เนื้อหาที่เก็บถาวรแล้ว title: เนื้อหาที่เก็บถาวรแล้ว
more: อื่นๆ นอกจากนี้ more: อื่นๆ นอกจากนี้
tagCloud:
title: แท็ก
search: search:
title: ค้นหา title: ค้นหา

View File

@ -23,8 +23,6 @@ widget:
archives: archives:
title: Arşiv title: Arşiv
more: Daha fazla more: Daha fazla
tagCloud:
title: Etiketler
search: search:
title: Arama title: Arama

View File

@ -29,8 +29,6 @@ widget:
archives: archives:
title: Архіви title: Архіви
more: Більше more: Більше
tagCloud:
title: Теґи
search: search:
title: Пошук title: Пошук

View File

@ -48,14 +48,6 @@ widget:
more: more:
other: Còn nữa other: Còn nữa
tagCloud:
title:
other: Nhãn dán
categoriesCloud:
title:
other: Chuỗi bài
search: search:
title: title:
other: Tìm kiếm other: Tìm kiếm

View File

@ -17,10 +17,6 @@ widget:
archives: archives:
title: 归档 title: 归档
more: 更多 more: 更多
tagCloud:
title: 标签云
categoriesCloud:
title: 分类
search: search:
title: 搜索 title: 搜索

View File

@ -28,10 +28,6 @@ widget:
archives: archives:
title: Archives title: Archives
more: 更多 more: 更多
tagCloud:
title: Tags
categoriesCloud:
title: Categories
search: search:
title: 搜尋 title: 搜尋

View File

@ -29,10 +29,6 @@ widget:
archives: archives:
title: 紀錄 title: 紀錄
more: 更多 more: 更多
tagCloud:
title: 標籤雲
categoriesCloud:
title: 分類
search: search:
title: 搜尋 title: 搜尋

View File

@ -11,7 +11,7 @@
<div class="section-card"> <div class="section-card">
<div class="section-details"> <div class="section-details">
<h3 class="section-count">{{ T "list.page" (len .Pages) }}</h3> <h3 class="section-count">{{ T "list.page" (len .Pages) }}</h3>
<h1 class="section-term">{{ .Title }}</h1> <h1 class="section-term">{{ default (strings.FirstUpper .Type) .Title }}</h1>
{{ with .Params.description }} {{ with .Params.description }}
<h2 class="section-description">{{ . }}</h2> <h2 class="section-description">{{ . }}</h2>
{{ end }} {{ end }}

View File

@ -7,7 +7,9 @@
<div class="widget-icon"> <div class="widget-icon">
{{ partial "helper/icon" "infinity" }} {{ partial "helper/icon" "infinity" }}
</div> </div>
<h2 class="widget-title section-title">{{ T "widget.archives.title" }}</h2> <h2 class="widget-title section-title">
<a class="widget-link" href="{{ $archivesPage.RelPermalink }}">{{ T "widget.archives.title" }}</a>
</h2>
{{ $pages := where $context.Site.RegularPages "Type" "in" $context.Site.Params.mainSections }} {{ $pages := where $context.Site.RegularPages "Type" "in" $context.Site.Params.mainSections }}
{{ $archives := $pages.GroupByDate "2006" }} {{ $archives := $pages.GroupByDate "2006" }}

View File

@ -1,16 +0,0 @@
{{- $context := .Context -}}
{{- $limit := default 10 .Params.limit -}}
<section class="widget tagCloud">
<div class="widget-icon">
{{ partial "helper/icon" "categories" }}
</div>
<h2 class="widget-title section-title">{{ T "widget.categoriesCloud.title" }}</h2>
<div class="tagCloud-tags">
{{ range first $limit $context.Site.Taxonomies.categories.ByCount }}
<a href="{{ .Page.RelPermalink }}" class="font_size_{{ .Count }}">
{{ .Page.Title }}
</a>
{{ end }}
</div>
</section>

View File

@ -1,16 +0,0 @@
{{- $context := .Context -}}
{{- $limit := default 10 .Params.limit -}}
<section class="widget tagCloud">
<div class="widget-icon">
{{ partial "helper/icon" "tag" }}
</div>
<h2 class="widget-title section-title">{{ T "widget.tagCloud.title" }}</h2>
<div class="tagCloud-tags">
{{ range first $limit $context.Site.Taxonomies.tags.ByCount }}
<a href="{{ .Page.RelPermalink }}" class="font_size_{{ .Count }}">
{{ .Page.Title }}
</a>
{{ end }}
</div>
</section>

View File

@ -0,0 +1,32 @@
{{- $query := first 1 (where (where .Context.Site.Pages "Kind" "taxonomy") "Type" .Params.type) -}}
{{- $context := .Context -}}
{{- $limit := default 10 .Params.limit -}}
{{- $hideInTaxonomyPage := default true .Params.hideInTaxonomyPage -}}
{{- if $query -}}
{{- $taxonomyPage := index $query 0 -}}
{{- $isTaxonomyPage := eq .Context $taxonomyPage -}}
{{- if not (and $isTaxonomyPage $hideInTaxonomyPage) -}}
<section class="widget tagCloud">
<div class="widget-icon">
{{- partial "helper/icon" (default "tag" .Params.icon) -}}
</div>
<h2 class="widget-title section-title">
<a class="widget-link" href="{{ $taxonomyPage.RelPermalink }}">
{{- default $taxonomyPage.Title .Params.title -}}
</a>
</h2>
<div class="tagCloud-tags">
{{- $pages := index $context.Site.Taxonomies .Params.type -}}
{{- $pagesSorted := $pages.ByCount -}}
{{- range first $limit $pagesSorted -}}
<a href="{{ .Page.RelPermalink }}">
{{- .Page.Title -}}
</a>
{{- end -}}
</div>
</section>
{{- end -}}
{{- else -}}
{{- warnf "Taxonomy [%s] not found." .Params.type -}}
{{- end -}}