{{- /* Tags Page */ -}}
{{- $tagCloud := .Site.Params.tag_cloud -}}

<div class="tags{{ with $tagCloud.enable }} tag-cloud-tags{{ end }}">
  {{- /* Tags Cloud */ -}}
  {{- if $tagCloud.enable -}}
    {{- $tags := cond (eq $tagCloud.orderby "name") $.Site.Taxonomies.tags.Alphabetical $.Site.Taxonomies.tags.ByCount -}}
    {{- $baseGrade := div ($tagCloud.peak_count | default 10) 10.0 -}}
    {{- $minFont := $tagCloud.min | default 16 -}}
    {{- $baseFont := div (sub ($tagCloud.max | default 32) $minFont) 10.0 -}}
    {{- range $tags -}}
      {{- $grade := math.Min (math.Floor (div (sub .Count 1) $baseGrade)) 10 -}}
      {{- $fontSize := add $minFont (mul $grade $baseFont) -}}
      <a href='{{ partial "function/escapeurl.html" .Page.RelPermalink }}' class="tag-item" data-grade="{{ $grade }}" style="--fi-tag-cloud-font: {{ $fontSize }}px">{{ .Page.LinkTitle }} <sup>{{ .Count }}</sup></a>
    {{- end -}}
  {{- else -}}
    {{- range $.Site.Taxonomies.tags.ByCount -}}
      <a href='{{ partial "function/escapeurl.html" .Page.RelPermalink }}' class="tag-item">{{ .Page.LinkTitle }} <sup>{{ .Count }}</sup></a>
    {{- end -}}
  {{- end -}}
</div>
