{{/* tag-cloud.html Reusable tag cloud partial for homepage, sidebar, and 404 pages. Params (dict): page Page required — calling page context (provides .Site.Taxonomies.tags, .Lang) showCount bool optional — show post count per tag (default true) heading string optional — heading text override (default: i18n "tagCloud") headingLevel string optional — h2|h3|p for non-widget mode (default "h2") wrapInWidget bool optional — wrap in .sidebar-widget for sidebar placement (default false) maxTags int optional — max tags to show, 0 = all (default 0) */}} {{- $page := .page -}} {{- $showCount := .showCount | default true -}} {{- $heading := .heading | default (i18n "tagCloud") -}} {{- $headingLevel := .headingLevel -}} {{- $wrapInWidget := .wrapInWidget | default false -}} {{- $maxTags := .maxTags | default 0 -}} {{- $tags := $page.Site.Taxonomies.tags -}} {{/* Early exit if no tags */}} {{- if $tags -}} {{/* Compute max count for continuous scaling */}} {{- $maxCount := 0 -}} {{- range $tags -}} {{- if gt .Count $maxCount -}}{{- $maxCount = .Count -}}{{- end -}} {{- end -}} {{/* Ordered tag list (descending by count) */}} {{- $orderedTags := $tags.ByCount -}} {{- if gt $maxTags 0 -}} {{- $orderedTags = first $maxTags $orderedTags -}} {{- end -}} {{/* Render based on placement mode */}} {{- if $wrapInWidget -}}