diff options
| author | Danilo M. <danix@danix.xyz> | 2026-04-21 23:10:48 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-04-21 23:10:48 +0200 |
| commit | 8bcdbe5ab1d02213786b8527d97b60ff7464fb7d (patch) | |
| tree | 85e0794d16c8cf4ea5bc96aaea45160cbe97bd3c | |
| parent | afa8811106653a59444cad423da17ba2932030df (diff) | |
| download | danixxyz-8bcdbe5ab1d02213786b8527d97b60ff7464fb7d.tar.gz danixxyz-8bcdbe5ab1d02213786b8527d97b60ff7464fb7d.zip | |
feat: replace tier-based sizing with continuous scaling in tag cloud
- Compute size per tag: 0.6rem + (count/maxCount) * 1.2rem
- Compute opacity per tag: 0.7 + (count/maxCount) * 0.3
- Color gradient: small tags var(--text-dim), large (>50%) tags var(--accent)
- Remove .tag-tier-* classes, use inline style attributes
- Update sidebar label to use topTags i18n key
| -rw-r--r-- | themes/danix-xyz-hacker/layouts/partials/tag-cloud.html | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/themes/danix-xyz-hacker/layouts/partials/tag-cloud.html b/themes/danix-xyz-hacker/layouts/partials/tag-cloud.html index 0d59e3c..0db75f0 100644 --- a/themes/danix-xyz-hacker/layouts/partials/tag-cloud.html +++ b/themes/danix-xyz-hacker/layouts/partials/tag-cloud.html @@ -22,16 +22,12 @@ {{/* Early exit if no tags */}} {{- if $tags -}} -{{/* Compute max count for tier thresholds */}} +{{/* Compute max count for continuous scaling */}} {{- $maxCount := 0 -}} {{- range $tags -}} {{- if gt .Count $maxCount -}}{{- $maxCount = .Count -}}{{- end -}} {{- end -}} -{{/* Tier thresholds (integer division) */}} -{{- $tierMedThreshold := div $maxCount 3 -}} -{{- $tierHighThreshold := mul (div $maxCount 3) 2 -}} - {{/* Ordered tag list (descending by count) */}} {{- $orderedTags := $tags.ByCount -}} {{- if gt $maxTags 0 -}} @@ -41,7 +37,7 @@ {{/* Render based on placement mode */}} {{- if $wrapInWidget -}} <div class="sidebar-widget"> - <p class="sidebar-widget-label"># {{ i18n "tags" }}</p> + <p class="sidebar-widget-label"># {{ i18n "topTags" }}</p> <nav aria-label="{{ i18n "exploreTopics" }}"> <div class="tag-cloud"> {{- else -}} @@ -55,15 +51,14 @@ {{- range $orderedTags -}} {{- $count := .Count -}} - {{- $tier := "low" -}} - {{- if gt $count $tierHighThreshold -}} - {{- $tier = "high" -}} - {{- else if gt $count $tierMedThreshold -}} - {{- $tier = "medium" -}} - {{- end -}} + {{- $ratio := (div (float $count) (float $maxCount)) -}} + {{- $size := (add 0.6 (mul $ratio 1.2)) -}} + {{- $opacity := (add 0.7 (mul $ratio 0.3)) -}} + {{- $color := cond (ge $ratio 0.5) "var(--accent)" "var(--text-dim)" -}} <a href="{{ .Page.RelPermalink }}" - class="tag-cloud-link tag-tier-{{ $tier }}" + class="tag-cloud-link" + style="font-size: {{ $size }}rem; color: {{ $color }}; opacity: {{ $opacity }};" aria-label="{{ .Name }}{{- if $showCount }} ({{ i18n "postCount" $count }}){{- end -}}" > {{- .Name -}} |
