Skip to content

Commit

Permalink
Fix #40 (terms.html gives back error for 0 value)
Browse files Browse the repository at this point in the history
  • Loading branch information
dataCobra committed Dec 17, 2020
1 parent e1a3861 commit 32489b9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions layouts/_default/terms.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{{ define "main" -}}
<h1 class="page-title">{{ .Name }}</h1>
<div class="tag-cloud">
{{ $max := len (index $.Site.Taxonomies.tags.ByCount 0).Pages }}
{{ $min := len (index $.Site.Taxonomies.tags.ByCount.Reverse 0).Pages }}

{{ $maxFontSize := 2.5 }}
{{ $minFontSize := 1.0 }}
{{ if .Data.Terms }}
{{ $max := add (len (index $.Data.Terms.ByCount 0).Pages) 0.001 }}
{{ $min := len (index $.Data.Terms.ByCount.Reverse 0).Pages }}
{{ $maxFontSize := 3.0 }}
{{ $minFontSize := 1.5 }}
{{ $steps := div (sub $maxFontSize $minFontSize) (sub $max $min) }}

{{ $data := .Data }}
Expand All @@ -16,5 +16,6 @@ <h1 class="page-title">{{ .Name }}</h1>
{{ $curFontSize := (add $minFontSize (mul (sub $maxFontSize $minFontSize) $weigth) ) }}
<a style="font-size: {{ $curFontSize }}rem;" href="{{ absURL $data.Plural }}/{{ $value.Name }}/">{{ $value.Name }}<sup>{{ $value.Count }}</sup></a>
{{ end }}
{{ end }}
</div>
{{ end }}

0 comments on commit 32489b9

Please sign in to comment.