1{{ define "main" }}
2{{ partial "cloud-hero.html" (upper .Title) }}
3<div class="section shell--narrow">
4 <header class="section-header">
5 <div class="section-header__top">
6 <h1 class="label">{{ .Title }}</h1>
7 </div>
8 <p class="section-header__desc">{{ with .Content }}{{ . | plainify }}{{ else }}Everything I write about, sorted by how often it comes up.{{ end }}</p>
9 </header>
10
11 {{- $showDrafts := hugo.IsDevelopment -}}
12 {{ if not $showDrafts }}
13 {{ with .Data.Terms.ByCount }}
14 <ul class="tag-list list-none">
15 {{ range . }}
16 <li class="tag-list__item">
17 <a href="{{ .Page.RelPermalink }}" class="tag-list__link">
18 <span class="tag-list__name">{{ .Term }}</span>
19 <span class="tag-list__count">{{ .Count }}</span>
20 </a>
21 </li>
22 {{ end }}
23 </ul>
24 {{ else }}
25 <p class="post-empty">No tags found yet.</p>
26 {{ end }}
27 {{ else }}
28 {{- $scratch := newScratch -}}
29 {{- $scratch.Set "tagData" (slice) -}}
30 {{- range .Site.RegularPages -}}
31 {{- if or (not .Draft) $showDrafts -}}
32 {{- with .Params.tags -}}
33 {{- range . -}}
34 {{- $tag := . -}}
35 {{- $slug := urlize $tag -}}
36 {{- $countKey := printf "count-%s" $slug -}}
37 {{- $count := $scratch.Get $countKey | default 0 -}}
38 {{- $scratch.Set $countKey (add $count 1) -}}
39 {{- $scratch.SetInMap "tagNames" $slug $tag -}}
40 {{- end -}}
41 {{- end -}}
42 {{- end -}}
43 {{- end -}}
44 {{- $tagNames := $scratch.Get "tagNames" -}}
45 {{- $tagData := slice -}}
46 {{- range $slug, $name := $tagNames -}}
47 {{- $countKey := printf "count-%s" $slug -}}
48 {{- $count := $scratch.Get $countKey | default 0 -}}
49 {{- $tagData = $tagData | append (dict "slug" $slug "name" $name "count" $count) -}}
50 {{- end -}}
51 {{- $sorted := sort $tagData "count" "desc" -}}
52 {{ if gt (len $sorted) 0 }}
53 <ul class="tag-list list-none">
54 {{ range $sorted }}
55 <li class="tag-list__item">
56 <a href="{{ (printf "/tags/%s" .slug) | relLangURL }}" class="tag-list__link">
57 <span class="tag-list__name">{{ .name }}</span>
58 <span class="tag-list__count">{{ .count }}</span>
59 </a>
60 </li>
61 {{ end }}
62 </ul>
63 {{ else }}
64 <p class="post-empty">No tags found yet.</p>
65 {{ end }}
66 {{ end }}
67
68 <div class="tag-back">
69 <a href="{{ "/blog/" | relLangURL }}" class="tag-back__link">Blog</a>
70 </div>
71</div>
72{{ end }}