diff options
| author | eltrac <hi@eltr.ac> | 2026-04-07 14:53:17 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-04-07 14:53:17 +0800 |
| commit | 10431bd8f5ff71690ae4e5444e8d7894fd401ae5 (patch) | |
| tree | 62b7fd1b6c1f68d2804f380eb522bcebeb2c8d9f /layouts/_partials/stats | |
| parent | 3e0edacc4a0cafa53ede57ebb6f0378c93f3123b (diff) | |
chore: move templates out of site repo
Diffstat (limited to 'layouts/_partials/stats')
| -rw-r--r-- | layouts/_partials/stats/external-link-rank.html | 37 | ||||
| -rw-r--r-- | layouts/_partials/stats/publish-time-chart.html | 78 | ||||
| -rw-r--r-- | layouts/_partials/stats/stats-table.html | 44 | ||||
| -rw-r--r-- | layouts/_partials/stats/word-count-chart.html | 46 |
4 files changed, 0 insertions, 205 deletions
diff --git a/layouts/_partials/stats/external-link-rank.html b/layouts/_partials/stats/external-link-rank.html deleted file mode 100644 index 4268d4d9..00000000 --- a/layouts/_partials/stats/external-link-rank.html +++ /dev/null @@ -1,37 +0,0 @@ -{{/* 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> diff --git a/layouts/_partials/stats/publish-time-chart.html b/layouts/_partials/stats/publish-time-chart.html deleted file mode 100644 index 3fa35078..00000000 --- a/layouts/_partials/stats/publish-time-chart.html +++ /dev/null @@ -1,78 +0,0 @@ -{{/* 定义时间段 */}} -{{ $fuzzyTimes := slice - (dict "limit" 5 "label" "凌晨" "class" "dawn") - (dict "limit" 11 "label" "早上" "class" "morning") - (dict "limit" 13 "label" "中午" "class" "noon") - (dict "limit" 17 "label" "下午" "class" "afternoon") - (dict "limit" 22 "label" "晚上" "class" "night") - (dict "limit" 24 "label" "深夜" "class" "late-night") -}} - -{{/* 初始化时间段计数 */}} -{{ $timeCounts := dict - "凌晨" 0 - "清晨" 0 - "早上" 0 - "中午" 0 - "下午" 0 - "傍晚" 0 - "晚上" 0 - "深夜" 0 -}} - -{{/* 统计每个时间段的文章数量 */}} -{{ $total := 0 }} -{{ range .Site.RegularPages }} - {{ if .Date }} - {{ $hour := .Date.Hour }} - {{ $fuzzyTime := "深夜" }} - {{ range $fuzzyTimes }} - {{ if lt $hour .limit }} - {{ $fuzzyTime = .label }} - {{ break }} - {{ end }} - {{ end }} - {{ $total = add $total 1 }} - {{ $currentCount := index $timeCounts $fuzzyTime }} - {{ $timeCounts = merge $timeCounts (dict $fuzzyTime (add $currentCount 1)) }} - {{ end }} -{{ end }} - -<div class="w-full max-w-[700px] my-4"> - <div class="flex items-center gap-4 mb-4"> - <div class="text-size-2xl flex-shrink-0">☀️</div> - <div class="flex gap-2 w-full h-6 dark:invert"> - {{ range $fuzzyTimes }} - {{ $count := index $timeCounts .label }} - {{ if gt $total 0 }} - {{ $percentage := div (mul $count 100.0) $total }} - {{ if gt $count 0 }} - <div class="flex items-center justify-center - text-white rounded-2xl text-size-sm font-500 relative - bg-black opacity-{{ add (mul (int (div $percentage 10)) 10) 30 }} - {{ .class }}" - style="width: {{ printf "%.1f" $percentage }}%;" - title="{{ .label }}: {{ $count }}篇 ({{ printf "%.1f" $percentage }}%)"> - {{ if gt $percentage 8 }}{{ .label }}{{ end }} - </div> - {{ end }} - {{ end }} - {{ end }} - </div> - <div class="text-size-2xl flex-shrink-0">🌙</div> - </div> - - <div class="flex gap-2 mt-2 px-10"> - {{ range $fuzzyTimes }} - {{ $count := index $timeCounts .label }} - {{ if gt $count 0 }} - {{ $percentage := div (mul $count 100.0) $total }} - <div class="flex flex-col items-center text-size-xs - text-secondary font-mono" - style="width: {{ printf "%.1f" $percentage }}%;"> - <span class="font-600 text-[var(--primary-text-color)]">{{ $count }}</span> - </div> - {{ end }} - {{ end }} - </div> -</div> diff --git a/layouts/_partials/stats/stats-table.html b/layouts/_partials/stats/stats-table.html deleted file mode 100644 index bb936721..00000000 --- a/layouts/_partials/stats/stats-table.html +++ /dev/null @@ -1,44 +0,0 @@ -<style> -.site-stats-table td { - padding: 0.5rem; - text-align: left; -} -.site-stats-table td:nth-child(2n) { - text-align: right; -} -.number-pill { - text-align: center; - display: inline-block; - line-height: 1.75rem; - box-sizing: border-box; - border-radius: 5px; - padding: 0 0.5rem; - background-color: var(--block-background-color); - font-size: 1rem; -} -</style> - -<table class="site-stats-table w-full max-w-[700px] border-collapse mb-6"> - <tbody> - <tr> - <td>页面总数</td> - <td><span class="number-pill">{{ len .Site.RegularPages }}</span></td> - <td>总字数</td> - <td> - <span class="number-pill"> - {{- $words := 0 -}} - {{- range (where .Site.RegularPages "Section" "!=" "") -}} - {{- $words = add $words .WordCount -}} - {{- end -}} - {{ lang.FormatNumber 0 $words }} - </span> - </td> - </tr> - <tr> - <td>标签总数</td> - <td><span class="number-pill">{{ len .Site.Taxonomies.tags }}</span></td> - <td>文章系列数量</td> - <td><span class="number-pill">{{ len .Site.Taxonomies.categories }}</span></td> - </tr> - </tbody> -</table> diff --git a/layouts/_partials/stats/word-count-chart.html b/layouts/_partials/stats/word-count-chart.html deleted file mode 100644 index 835ecbda..00000000 --- a/layouts/_partials/stats/word-count-chart.html +++ /dev/null @@ -1,46 +0,0 @@ -{{/* Group word counts per month */}} -{{ $monthly := dict }} -{{ range .Site.RegularPages }} - {{ $month := .Date.Format "2006-01" }} - {{ $count := .WordCount }} - {{ with index $monthly $month }} - {{ $monthly = merge $monthly (dict $month (add . $count)) }} - {{ else }} - {{ $monthly = merge $monthly (dict $month $count) }} - {{ end }} -{{ end }} - -{{/* Sort months */}} -{{ $months := slice }} -{{ range $month, $_ := $monthly }} - {{ $months = $months | append $month }} -{{ end }} -{{ $months = sort $months }} - -{{/* Find max value */}} -{{ $max := 0 }} -{{ range $month := $months }} - {{ $val := index $monthly $month }} - {{ if gt $val $max }}{{ $max = $val }}{{ end }} -{{ end }} - -<div class="flex items-end justify-end h-[300px] gap-2 px-4 - text-size-xs w-full overflow-x-auto box-border"> - {{ range $month := $months }} - {{ $val := index $monthly $month }} - {{ $height := mul (div (float $val) (float $max)) 100 }} - {{ $opacity := add 0.5 (div $height 200) }} - <div class="flex flex-col justify-center"> - <div class="flex flex-col items-center justify-end - w-4 gap-1 h-[200px] relative"> - <div class="text-size-[0.65rem]" - style="writing-mode: vertical-rl;">{{ $val }}</div> - <div class="w-full bg-gray-900 flex-shrink-0 transition dark:invert" - style="height: {{ printf "%.1f" $height }}%; - background-color: rgba(20,20,20,{{ printf "%.2f" $opacity }});"></div> - </div> - <div class="h-12 text-center flex-shrink" - style="writing-mode: vertical-rl;">{{ $month }}</div> - </div> - {{ end }} -</div> |
