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:
@@ -11,7 +11,7 @@
|
||||
<div class="section-card">
|
||||
<div class="section-details">
|
||||
<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 }}
|
||||
<h2 class="section-description">{{ . }}</h2>
|
||||
{{ end }}
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
<div class="widget-icon">
|
||||
{{ partial "helper/icon" "infinity" }}
|
||||
</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 }}
|
||||
{{ $archives := $pages.GroupByDate "2006" }}
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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 -}}
|
||||
Reference in New Issue
Block a user