mirror of
https://github.com/Aroy-Art/Rinkusu.git
synced 2024-12-27 23:34:24 +01:00
Add: tagcloud.html partial
This commit is contained in:
parent
57cd94e514
commit
b4ee8114ba
1 changed files with 22 additions and 0 deletions
22
layouts/partials/tagcloud.html
Normal file
22
layouts/partials/tagcloud.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<div class="container tagcloud">
|
||||
<h4>Tags</h4>
|
||||
{{ if ne (len $.Site.Taxonomies.tags) 0 }}
|
||||
{{ $largestFontSize := 1.4 }}
|
||||
{{ $smallestFontSize := 1.0 }}
|
||||
{{ $fontSpread := sub $largestFontSize $smallestFontSize }}
|
||||
{{ $max := add (len (index $.Site.Taxonomies.tags.ByCount 0).Pages) 1 }}
|
||||
{{ $min := len (index $.Site.Taxonomies.tags.ByCount.Reverse 0).Pages }}
|
||||
{{ $spread := sub $max $min }}
|
||||
{{ $fontStep := div $fontSpread $spread }}
|
||||
{{ range $name, $taxonomy := $.Site.Taxonomies.tags }}
|
||||
{{ $tagCount := len $taxonomy.Pages }}
|
||||
{{ $currentFontSize := (add $smallestFontSize (mul (sub $tagCount $min) $fontStep) ) }}
|
||||
{{ $weight := div (sub (math.Log $tagCount) (math.Log $min)) (sub (math.Log $max) (math.Log $min)) }}
|
||||
{{ $currentFontSize := (add $smallestFontSize (mul (sub $largestFontSize $smallestFontSize) $weight)) }}
|
||||
<a href="{{ "/tags/" | relURL }}{{ $name | urlize }}"
|
||||
class="tagcloud-item" style="font-size: {{ $currentFontSize }}rem;">
|
||||
{{ $name }}<sup>{{ $tagCount }}</sup>
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
Loading…
Reference in a new issue