added all files from previous iterations
[theme-danix.xyz.git] / layouts / partials / tag-cloud.html
1 {{ if $.Site.Taxonomies.tags }}
2 {{- if not (eq (len $.Site.Taxonomies.tags) 0) -}}
3 {{- $fontUnit := "rem" -}}
4 {{- $largestFontSize := 2.0 -}}
5 {{- $largestFontSize := 2.5 -}}
6 {{- $smallestFontSize := 1.0 -}}
7 {{- $fontSpread := sub $largestFontSize $smallestFontSize -}}
8 {{- $max := add (len (index $.Site.Taxonomies.tags.ByCount 0).Pages) 1 -}}
9 {{- $min := len (index $.Site.Taxonomies.tags.ByCount.Reverse 0).Pages -}}
10 {{- $spread := sub $max $min -}}
11 {{- $fontStep := div $fontSpread $spread -}}
12
13 <div id="tag-cloud">
14 <h3>here we talk about..</h3>
15 {{- range $name, $taxonomy := $.Site.Taxonomies.tags -}}
16 {{- $currentTagCount := len $taxonomy.Pages -}}
17 {{- $currentFontSize := (add $smallestFontSize (mul (sub $currentTagCount $min) $fontStep) ) -}}
18 {{- $count := len $taxonomy.Pages -}}
19 {{- $weigth := div (sub (math.Log $count) (math.Log $min)) (sub (math.Log $max) (math.Log $min)) -}}
20 {{- $currentFontSize := (add $smallestFontSize (mul (sub $largestFontSize $smallestFontSize) $weigth) ) -}}
21 <!--Current font size: {{$currentFontSize}}-->
22 <a class="tag-cloud-link" href="{{ "/tags/" | relLangURL }}{{ $name | urlize }}" style="font-size:{{$currentFontSize}}{{$fontUnit}}">{{ $name }}</a>
23 {{- end -}}
24 </div>
25 {{- end -}}
26 {{- else -}}
27 <div id="tag-cloud">
28 <p>here will appear the tag cloud as soon as we have tags :)</p>
29 </div>
30 {{- end -}}