blob: 6cebc165dfdb1bd35290b8dd738d6c8be844b946 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
{{ define "title" }}{{ i18n .Data.Plural }} - {{ .Site.Title }}{{ end }}
{{ define "content" }}
{{ $name := .Data.Plural -}}
{{ $terms := .Data.Terms.ByCount -}}
{{ $length := len $terms -}}
{{ if eq $name "categories" }}
{{ range $key, $value := $terms }}
<section id="archive" class="archive">
<div class="archive-title">
</div>
<div class="collection-title">
<h2 class="archive-year">
<a href="{{ $name | urlize | relURL }}/{{ $value.Term | urlize }}/">
{{ i18n "category" }}{{ $value.Term }}
</a>
</h2>
</div>
{{- range first 5 $value.Pages -}}
<div class="archive-post">
<span class="archive-post-time">
{{ .Date.Format "2006-01-02" }}
</span>
<span class="archive-post-title">
<a href="{{ .URL }}" class="archive-post-link">
{{ .Title }}
</a>
</span>
</div>
{{- end -}}
{{ if gt (len $value.Pages) 5 }}
<div class="more-post">
<a href="{{ $name | urlize | relURL }}/{{ $value.Term | urlize }}/" class="more-post-link">{{ i18n "morePost" }}</a>
</div>
{{- end -}}
</section>
{{- end -}}
{{ else if eq $name "tags" }}
{{ if not (eq (len $.Site.Taxonomies.tags) 0) }}
{{ $fontUnit := "rem" }}
{{ $largestFontSize := 2.0 }}
{{ $largestFontSize := 2.5 }}
{{ $smallestFontSize := 1.0 }}
{{ $fontSpread := sub $largestFontSize $smallestFontSize }}
{{ $max := add (len (index $.Site.Taxonomies.tags.ByCount 0).Pages) 1 }}
{{ $min := len (index $.Site.Taxonomies.tags.ByCount.Reverse 0).Pages }}
{{ $spread := sub $max $min }}
{{ $fontStep := div $fontSpread $spread }}
<div class="tag-cloud" style="padding: 5px 15px">
<div class="tag-cloud-title">
{{ i18n "counter_tagcloud" $length}}
</div>
<div class="tag-cloud-tags">
{{ range $name, $taxonomy := $.Site.Taxonomies.tags }}
{{ $currentTagCount := len $taxonomy.Pages }}
{{ $currentFontSize := (add $smallestFontSize (mul (sub $currentTagCount $min) $fontStep) ) }}
{{ $count := len $taxonomy.Pages }}
{{ $weigth := div (sub (math.Log $count) (math.Log $min)) (sub (math.Log $max) (math.Log $min)) }}
{{ $currentFontSize := (add $smallestFontSize (mul (sub $largestFontSize $smallestFontSize) $weigth) ) }}
<!--Current font size: {{$currentFontSize}}-->
<a href="{{ "/tags/" | relLangURL }}{{ $name | urlize }}" style="font-size:{{$currentFontSize}}{{$fontUnit}}">{{ $name }}</a>
{{ end }}
</div>
</div>
{{ end }}
{{ end }}
{{ end }}
|