Simon Gardling 032679b34a setup
2023-10-11 17:38:05 -04:00

26 lines
904 B
HTML

{{ if . }}
{{ $fontSmall := 1 }}
{{ $fontBig := 1.6 }}
{{ $fontSpread := sub $fontBig $fontSmall }}
{{ $termCount := slice }}
{{ range . }}
{{ $termCount = append .Count $termCount }}
{{ end }}
{{ $termCount = sort $termCount }}
{{ $min := int (index $termCount 0) }}
{{ $max := add (int (index $termCount (sub (len $termCount) 1))) 1 }}
<div>
{{ range . }}
{{ $weight := div (sub (math.Log .Count) (math.Log $min)) (sub (math.Log $max) (math.Log $min)) }}
{{ $fontSize := (add $fontSmall (mul $fontSpread $weight)) }}
<a class="term-item" href="{{ .Page.RelPermalink }}">
<span style="font-size:{{ $fontSize }}rem">{{- .Page.Title -}}</span>
<span style="font-size:{{ sub $fontSmall 0.2 }}rem"> ({{- .Count -}}) </span>
</a>
{{ end }}
</div>
{{ end }}