diff options
| author | Eltrac <hi@guhub.cn> | 2024-12-01 22:58:31 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2024-12-01 22:58:31 +0800 |
| commit | 473ebc56c3566ac895725ffab0d9e24f452b993d (patch) | |
| tree | 0ee9473701cad4000ebab4c6c3c68cd7d0b50246 | |
| parent | 3416a057ff68d4bdba8d122889fc2c37df989514 (diff) | |
feat: article word count for cal heatmap
| -rw-r--r-- | hugo.toml | 8 | ||||
| -rw-r--r-- | themes/yinyang/layouts/index.calheatmap.json | 15 |
2 files changed, 23 insertions, 0 deletions
@@ -39,3 +39,11 @@ target = "_blank" [services.rss] limit = 10 +[outputs] + home = ["HTML", "calheatmap"] + +[outputFormats] +[outputFormats.calheatmap] + mediaType = "application/json" + baseName = "cal-heatmap" + isPlainText = true diff --git a/themes/yinyang/layouts/index.calheatmap.json b/themes/yinyang/layouts/index.calheatmap.json new file mode 100644 index 00000000..65b1d942 --- /dev/null +++ b/themes/yinyang/layouts/index.calheatmap.json @@ -0,0 +1,15 @@ +{{- /* 设置 Content-Type 为 JSON */ -}} +{{- $entries := slice -}} +{{- range .Site.RegularPages -}} + {{- $wordCount := .WordCount -}} + {{- $date := .Date.Format "2006-01-02" -}} + {{- $entry := dict "date" $date "value" $wordCount -}} + {{- $entries = $entries | append $entry -}} +{{- end -}} +{{- $.Scratch.Add "results" $entries -}} +[ + {{- range $i, $entry := $.Scratch.Get "results" -}} + {{- if $i }},{{ end -}} + {{- $entry | jsonify -}} + {{- end -}} +] |
