blob: 4268d4d96fce52272ba5f8c088e6edc89569bc09 (
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
|
{{/* Find the maximum link count */}}
{{ $max := 0 }}
{{ range hugo.Data.externallinks }}
{{ if gt (index . 1) $max }}
{{ $max = index . 1 }}
{{ end }}
{{ end }}
{{/* Sort by count (descending) */}}
{{ $links := hugo.Data.externallinks }}
{{ $sorted := slice }}
{{ range $links }}
{{ $sorted = $sorted | append (dict "domain" (index . 0) "count" (index . 1)) }}
{{ end }}
{{ $sorted = sort $sorted "count" "desc" }}
<ol id="external-link-rank"
class="p-0! m-0 box-border">
{{ range $sorted }}
{{ $label := .domain }}
{{ $count := .count }}
{{ if gt $count 4 }}
{{ $percent := div (mul $count 100) $max }}
<li class="list-none w-full my-2 box-border py-[0.1rem] px-2 relative">
<div class="mx-2 flex justify-between items-center">
<a class="inline-flex items-center gap-2 no-icon" href="https://{{ $label }}/" target="_blank">
<img src="https://favicone.com/{{ $label }}?s=20"
class="w-4 h-4 m-0!" loading="lazy" />
{{ $label }}
</a>
<span class="text-secondary font-mono">{{ $count }}</span>
</div>
<div class="bg-gray-200 dark:bg-zinc-700 absolute top-0 left-0 right-0 bottom-0 -z-1" style="width:{{ $percent }}%"></div>
</li>
{{ end }}
{{ end }}
</ol>
|