Skip to content

Commit e31e4d4

Browse files
authored
Add back tag cloud removed by accident (#364)
1 parent 6167675 commit e31e4d4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

layouts/partials/posts/list.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,33 @@
11
<section class="section content-padding flex-row">
2+
<div class="tag-cloud is-hidden-mobile">
3+
<h2 class="tag-cloud-title">{{ i18n "tags" }}</h2>
4+
{{ if not (eq (len $.Site.Taxonomies.tags) 0) }}
5+
{{ $fontUnit := "rem" }}
6+
{{ $largestFontSize := 2.5 }}
7+
{{ $smallestFontSize := 1.0 }}
8+
{{ $fontSpread := sub $largestFontSize $smallestFontSize }}
9+
{{ $max := add (len (index $.Site.Taxonomies.tags.ByCount 0).Pages) 1 }}
10+
{{ $min := len (index $.Site.Taxonomies.tags.ByCount.Reverse 0).Pages }}
11+
{{ $spread := sub $max $min }}
12+
{{ $fontStep := div $fontSpread $spread }}
13+
<ul class="tag-cloud-item">
14+
{{ range $name, $taxonomy := $.Site.Taxonomies.tags }}
15+
{{ $currentTagCount := len $taxonomy.Pages }}
16+
{{ $currentFontSize := (add $smallestFontSize (mul (sub $currentTagCount $min) $fontStep) ) }}
17+
{{ $count := len $taxonomy.Pages }}
18+
{{ $weight := div (sub (math.Log $count) (math.Log $min)) (sub (math.Log $max) (math.Log $min)) }}
19+
{{ $currentFontSize := (add $smallestFontSize (mul (sub $largestFontSize $smallestFontSize) $weight) ) }}
20+
<li>
21+
<a href="{{ "/tags/" | relLangURL }}{{ $name | urlize }}"
22+
style="font-size:{{$currentFontSize}}{{$fontUnit}}"
23+
>
24+
{{ $name }}
25+
</a>
26+
</li>
27+
{{ end }}
28+
</ul>
29+
{{ end }}
30+
</div>
231
<div class="content-container">
332
{{ partial "breadcrumbs.html" . }}
433
<h1>{{ .Title }}</h1>

0 commit comments

Comments
 (0)