From 6b12d2da99af708a55b56d4e461154604544f401 Mon Sep 17 00:00:00 2001 From: Guilhem Bonnefille Date: Sun, 15 Nov 2020 15:27:48 +0100 Subject: [PATCH 1/2] Add a minimum value to display tags in widget The tag list in the Tag widget can be very long. With such feature, it is possible to limit to the most used tags. --- README.md | 1 + exampleSite/config.toml | 1 + layouts/partials/widgets/taglist.html | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 12d95511..82cbc96d 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ googleAnalytics = "" # Enable Google Analytics by entering your tracking id [Params.widgets] recent_num = 5 # Set the number of articles in the "Recent articles" widget tags_counter = false # Enable counter for each tag in "Tags" widget + tags_min_counter = 1 # Display only tags with a greater value [Params.widgets.social] # Enable parts of social widget diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 370ab4c6..8eb9efb4 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -33,3 +33,4 @@ googleAnalytics = "" # Enable Google Analytics by entering your tracking id [Params.widgets] recent_num = 5 # Set the number of articles in the "Recent articles" widget tags_counter = false # Enable counter for each tag in "Tags" widget (disabled by default) + tags_min_counter = 5 # Display only tags with greateror equal counter, to limit tag list diff --git a/layouts/partials/widgets/taglist.html b/layouts/partials/widgets/taglist.html index 4c51b04b..47eb13c3 100644 --- a/layouts/partials/widgets/taglist.html +++ b/layouts/partials/widgets/taglist.html @@ -5,11 +5,14 @@

{{ T "tags_title" }}

{{- range $name, $taxonomy := $tags }} {{- with $.Site.GetPage (printf "/tags/%s" $name) }} + {{/* Only render tags with a counter value greater than minimal settings */}} + {{- if ge $taxonomy.Count (default 0 .Site.Params.widgets.tags_min_counter) }} {{- .Title -}}{{- if .Site.Params.widgets.tags_counter }} ({{ $taxonomy.Count }}){{ end -}} {{- end }} + {{- end }} {{- end }}
-{{- end }} \ No newline at end of file +{{- end }} From 99a64358384f17af394030f8cc6135d72c713735 Mon Sep 17 00:00:00 2001 From: Guilhem Bonnefille Date: Sun, 15 Nov 2020 16:02:24 +0100 Subject: [PATCH 2/2] Add link to tags page if widget list is truncated When the widget list is truncated, it could be useful to have a direct link to the page listing all the available tags. --- i18n/en.yaml | 3 +++ i18n/fr.yaml | 3 +++ layouts/partials/widgets/taglist.html | 3 +++ 3 files changed, 9 insertions(+) diff --git a/i18n/en.yaml b/i18n/en.yaml index 3614cf05..95c464de 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -61,6 +61,9 @@ - id: tags_title translation: "Tags" +- id: all_tags + translation: "All tags" + # Footer - id: footer_credits translation: diff --git a/i18n/fr.yaml b/i18n/fr.yaml index 07963dbf..e90713e9 100644 --- a/i18n/fr.yaml +++ b/i18n/fr.yaml @@ -61,6 +61,9 @@ - id: tags_title translation: "Mots-clefs" +- id: all_tags + translation: "Tous les tags" + # Footer - id: footer_credits translation: diff --git a/layouts/partials/widgets/taglist.html b/layouts/partials/widgets/taglist.html index 47eb13c3..a9c36f30 100644 --- a/layouts/partials/widgets/taglist.html +++ b/layouts/partials/widgets/taglist.html @@ -14,5 +14,8 @@

{{ T "tags_title" }}

{{- end }} {{- end }} + {{- if ge .Site.Params.widgets.tags_min_counter 2 }} + {{ T "all_tags" }} + {{- end }} {{- end }}