From 1d6d44a0cd5665c6896ae6e160446d1109d37b01 Mon Sep 17 00:00:00 2001 From: paspo Date: Mon, 23 Sep 2024 20:09:40 +0000 Subject: [PATCH] tag cloud con font size variabile e soglia minima (#247) #232 attenzione!! conflitta con #246!! accettarne solo una delle due! Reviewed-on: https://git.libreschool.org/BgLUG/bglug.it/pulls/247 Co-authored-by: paspo Co-committed-by: paspo --- i18n/en.yaml | 1 + i18n/it.yaml | 1 + layouts/partials/sidebar/taglist.html | 58 +++++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/i18n/en.yaml b/i18n/en.yaml index 72a4720..498113d 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -9,3 +9,4 @@ subscribe_mailinglist: Subscribe to our mailing list subscribe: Subscribe come_and_see_us: Come and see us where: Where +more_tags: "...more" diff --git a/i18n/it.yaml b/i18n/it.yaml index 1e4b04e..47a5fe0 100644 --- a/i18n/it.yaml +++ b/i18n/it.yaml @@ -9,3 +9,4 @@ subscribe_mailinglist: Iscriviti alla mailing list subscribe: Iscriviti come_and_see_us: Vieni a trovarci where: Dove siamo +more_tags: "...altro" diff --git a/layouts/partials/sidebar/taglist.html b/layouts/partials/sidebar/taglist.html index a27d20c..ea1fa9d 100644 --- a/layouts/partials/sidebar/taglist.html +++ b/layouts/partials/sidebar/taglist.html @@ -1,11 +1,61 @@
+ + {{- $hiddenTags := slice "Linuxday-Featured" -}}

Tags

    - {{ range where .Site.Taxonomies.tags ".Page.Section" .Section }} - {{ if not (in $hiddenTags .Page.LinkTitle ) }} -
  • {{ .Page.LinkTitle | safeHTML }}
  • + + {{ $font_min := 1.0 }} + {{ $font_max := 3.5 }} + {{ $count_min_display := 3 }} + + {{ $tags := where .Site.Taxonomies.tags ".Page.Section" .Section }} + {{ $tags := where $tags ".Page.LinkTitle" "not in" $hiddenTags }} + {{ $count := len $tags }} + + {{ $count_min := -1 }} + {{ $count_max := -1 }} + + {{ range $tags }} + {{ $c := len .Pages }} + {{ if gt $c $count_max }} + {{ $count_max = $c }} + {{ end }} + {{ if le $count_min -1 }} + {{ $count_min = $c }} + {{ end }} + {{ if lt $c $count_min }} + {{ $count_min = $c }} {{ end }} {{ end }} -
+ + {{ if lt $count_min $count_min_display }} + {{ $count_min = $count_min_display }} + {{ end }} + + {{ $count_delta := sub $count_max $count_min }} + {{ $font_delta := sub $font_max $font_min }} + {{ $font_step := div $font_delta $count_delta }} + + {{/* range $tags.ByCount */}} + {{ range $tags.Alphabetical }} + {{ $c := len .Pages }} + {{ $font_size := (add $font_min (mul $c $font_step)) }} + {{ if ge $c $count_min_display }} +
  • + {{ .Page.LinkTitle | safeHTML }} ({{ len .Pages }})
  • + {{ else }} +
  • + {{ .Page.LinkTitle | safeHTML }} ({{ len .Pages }})
  • + {{ end }} + {{ end }} +
  • {{ T "more_tags" }}
  • +