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

terms.html « _default « layouts - github.com/xianmin/hugo-theme-jane.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 110cd63d3cb0cd0cea2e2ab4287d42e0822a2f20 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
{{ define "title" }}{{ i18n .Data.Plural | default (title .Data.Plural ) }} - {{ .Site.Title }}{{ end }}

{{ define "content" }}
  {{ $termName := .Data.Singular }}
  {{ $terms := .Data.Terms.ByCount }}
  {{ $length := len $terms }}
  {{ $type := .Type }}

  <!-- Categories Page -->
  {{ if and $.Site.Taxonomies.categories (eq $termName "category") }}
    {{ range $terms }}
    {{ $term := .Term }}
    {{ $pages := .Pages }}
    {{ with $.Site.GetPage "taxonomy" (printf "%s/%s" $type $term) }}
      <section id="archive" class="archive">
        <div class="archive-title">
        </div>
          <div class="collection-title">
            <h2 class="archive-year">
              <a href="{{ .Permalink }}">
                {{ i18n "category" }}{{ $term }}
              </a>
            </h2>
          </div>

          {{ range first 5 $pages }}
            <div class="archive-post">
              <time datetime="{{ .Date.Format "2006-01-02" }}" class="archive-post-time">
                {{ .Date.Format "2006-01-02" }}
              </time>
              <span class="archive-post-title">
                <a href="{{ .RelPermalink }}" class="archive-post-link">
                  {{ .Title }}
                </a>
              </span>
            </div>
          {{ end }}
          {{ if gt (len $pages) 5 }}
            <div class="more-post">
              <a href="{{ .Permalink }}" class="more-post-link">{{ i18n "morePost" }}</a>
            </div>
          {{ end }}
      </section>
    {{ end }}
    {{ end }}

  <!-- Tag cloud Page -->
  {{ else if and $.Site.Taxonomies.tags (eq $termName "tag") }}
    {{ $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 $tagName, $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) ) }}
        {{ with $.Site.GetPage "taxonomy" (printf "%s/%s" $type $tagName) }}
        <!--Current font size: {{$currentFontSize}}-->
        <a href="{{ .Permalink }}"
          style="font-size:{{$currentFontSize}}{{$fontUnit}}">{{ $tagName }}</a>
        {{ end }}
      {{ end }}
      </div>
    </div>
  <!-- Author Page -->
  {{ else if and $.Site.Taxonomies.author (eq $termName "author") }}
    {{ range $terms }}
    {{ $term := .Term }}
    {{ $pages := .Pages }}
    {{ with $.Site.GetPage "taxonomy" (printf "%s/%s" $type $term) }}
      <section id="archive" class="archive">
        <div class="archive-title">
        </div>
          <div class="collection-title">
            <h2 class="archive-year">
              <a href="{{ .Permalink }}">
                {{- $author := (index ($.Site.Data.authors | default dict) $term) -}}
                {{- $author_lang := (index ($author | default dict) $.Site.Language.Lang) -}}
                {{- $author_name := $author_lang.name.display | default $author.name.display | default $term -}}
                {{ i18n "author_item" }}{{ $author_name }}
              </a>
            </h2>
          </div>

          {{ range first 5 $pages }}
            <div class="archive-post">
              <time datetime="{{ .Date.Format "2006-01-02" }}" class="archive-post-time">
                {{ .Date.Format "2006-01-02" }}
              </time>
              <span class="archive-post-title">
                <a href="{{ .RelPermalink }}" class="archive-post-link">
                  {{ .Title }}
                </a>
              </span>
            </div>
          {{ end }}
          {{ if gt (len $pages) 5 }}
            <div class="more-post">
              <a href="{{ .Permalink }}" class="more-post-link">{{ i18n "morePost" }}</a>
            </div>
          {{ end }}
      </section>
    {{ end }}
    {{ end }}
  {{ else }}
  {{ range $terms }}
    {{ $term := .Term }}
    {{ $pages := .Pages }}
    {{ with $.Site.GetPage "taxonomy" (printf "%s/%s" $type $term)}}
    <section id="archive" class="archive">
      <div class="archive-title"></div>
      <div class="collection-title">
        <h2 class="archive-year">
          <a href="{{ .Permalink }}">
            {{ i18n $termName | default (printf "%s: " (title $termName)) }}{{ $term }}
          </a>
        </h2>
      </div>
      {{ range first 5 $pages }}
            <div class="archive-post">
              <time datetime="{{ .Date.Format "2006-01-02" }}" class="archive-post-time">
                {{ .Date.Format "2006-01-02" }}
              </time>
              <span class="archive-post-title">
                <a href="{{ .RelPermalink }}" class="archive-post-link">
                  {{ .Title }}
                </a>
              </span>
            </div>
          {{ end }}
          {{ if gt (len $pages) 5 }}
            <div class="more-post">
              <a href="{{ .Permalink }}" class="more-post-link">{{ i18n "morePost" }}</a>
            </div>
          {{ end }}
    </section>
    {{ end }}
  {{ end }}

  {{ end }}

{{ end }}