tag cloud con font size variabile e soglia minima #247
@ -9,3 +9,4 @@ subscribe_mailinglist: Subscribe to our mailing list
|
|||||||
subscribe: Subscribe
|
subscribe: Subscribe
|
||||||
come_and_see_us: Come and see us
|
come_and_see_us: Come and see us
|
||||||
where: Where
|
where: Where
|
||||||
|
more_tags: "...more"
|
||||||
|
@ -9,3 +9,4 @@ subscribe_mailinglist: Iscriviti alla mailing list
|
|||||||
subscribe: Iscriviti
|
subscribe: Iscriviti
|
||||||
come_and_see_us: Vieni a trovarci
|
come_and_see_us: Vieni a trovarci
|
||||||
where: Dove siamo
|
where: Dove siamo
|
||||||
|
more_tags: "...altro"
|
||||||
|
@ -1,11 +1,61 @@
|
|||||||
<section>
|
<section>
|
||||||
|
<script>
|
||||||
|
function show_all_tags(e) {
|
||||||
|
$(".tags-sidebar li").css("display","inline-block");
|
||||||
|
$(e).css("display","none");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
{{- $hiddenTags := slice "Linuxday-Featured" -}}
|
{{- $hiddenTags := slice "Linuxday-Featured" -}}
|
||||||
<h3>Tags</h3>
|
<h3>Tags</h3>
|
||||||
<ul class="tags-sidebar">
|
<ul class="tags-sidebar">
|
||||||
{{ range where .Site.Taxonomies.tags ".Page.Section" .Section }}
|
|
||||||
{{ if not (in $hiddenTags .Page.LinkTitle ) }}
|
{{ $font_min := 1.0 }}
|
||||||
<li><a href="/{{ .Page.Lang }}{{ .Page.Path }}">{{ .Page.LinkTitle | safeHTML }}</a></li>
|
{{ $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 }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
|
||||||
|
{{ 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 }}
|
||||||
|
<li>
|
||||||
|
<a style="font-size: {{ $font_size }}rem;" href="/{{ .Page.Lang }}{{ .Page.Path }}">{{ .Page.LinkTitle | safeHTML }} ({{ len .Pages }})</a></li>
|
||||||
|
{{ else }}
|
||||||
|
<li style="display: none;">
|
||||||
|
<a style="font-size: {{ $font_size }}rem;" href="/{{ .Page.Lang }}{{ .Page.Path }}">{{ .Page.LinkTitle | safeHTML }} ({{ len .Pages }})</a></li>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
<li><a href="#" onclick="return show_all_tags(this)">{{ T "more_tags" }}</a></li>
|
||||||
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user