Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dataCobra/hugo-vitae.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordataCobra <datacobra@thinkbot.de>2020-12-05 20:37:58 +0300
committerdataCobra <datacobra@thinkbot.de>2020-12-05 20:37:58 +0300
commit59a5e07b03ead913f2f86af4556014055833f1ed (patch)
tree035ed8a8351006c3a3b9709d42b28ab5e13fffec
parentb827e86d737d364a9f69093885834691c6166bb1 (diff)
Add tagcloud feature for terms.html
Taxonomy list pages are now displayed in a nice tagcloud and adjust automatically to look good.
-rw-r--r--layouts/_default/terms.html15
-rw-r--r--static/css/main.css2
2 files changed, 15 insertions, 2 deletions
diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html
index d601466..0730dc2 100644
--- a/layouts/_default/terms.html
+++ b/layouts/_default/terms.html
@@ -1,9 +1,20 @@
{{ define "main" -}}
<h2 class="page-title">{{ .Name }}</h2>
<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 }}
+ {{ $steps := div (sub $maxFontSize $minFontSize) (sub $max $min) }}
+
{{ $data := .Data }}
- {{ range $key, $value := .Data.Terms.ByCount }}
- <a href="{{ absURL $data.Plural }}/{{ $value.Name }}/">{{ $value.Name }}<sup>{{ $value.Count }}</sup></a>
+ {{ range $key, $value := .Data.Terms.Alphabetical }}
+ {{ $amountTags := len $data.Pages }}
+ {{ $curFontSize := (add $minFontSize (mul (sub $amountTags $min) $steps) ) }}
+ {{ $weigth := div (sub (math.Log $value.Count) (math.Log $min)) (sub (math.Log $max) (math.Log $min)) }}
+ {{ $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 }}
</div>
{{ end }}
diff --git a/static/css/main.css b/static/css/main.css
index cacab03..44a3017 100644
--- a/static/css/main.css
+++ b/static/css/main.css
@@ -406,6 +406,8 @@ table th {
.tag-cloud {
margin-top: 20px;
+ line-height: normal;
+ text-align: center;
}
.tag-cloud a {