{{ $scratch := newScratch }} {{ $scope := .Get 0 | default "posts" }} {{ $pages := where site.RegularPages "Type" "in" (slice "posts" "jottings" "readings" "tech") }} {{ if eq $scope "all" }} {{ $pages = where site.RegularPages "Type" "in" (slice "posts" "about" "newsgroup" "links" "jottings" "readings" "tech") }} {{ end }} {{ range $pages }} {{ if not (in .Params.categories "!往昔!") }} {{ $scratch.Add "wordcount" .WordCount }} {{ end }} {{ end }} {{ $count := $scratch.Get "wordcount" }} {{ if gt $count 0 }}
共书写了 {{ lang.FormatNumber 0 $count }} 字,{{ $readTime := div $count 400 }}预计需要阅读 {{ if lt $readTime 60 }}{{ $readTime }} 分钟{{ else }}{{ div (float $readTime) 60 | printf "%.1f" }} 小时{{ end }} ,{{ $classics := slice (dict "name" "红楼梦" "words" 731017) (dict "name" "金阁寺" "words" 125000) (dict "name" "了不起的盖茨比" "words" 49800) (dict "name" "呐喊" "words" 152000) (dict "name" "老人与海" "words" 26800) (dict "name" "1984" "words" 123000) (dict "name" "围城" "words" 257000) (dict "name" "飘" "words" 802000) }} {{ $closestBook := index $classics 0 }} {{ $minDiff := 99999999 }} {{ range $classics }} {{ $diff := sub $count .words }}{{ if lt $diff 0 }}{{ $diff = mul $diff -1 }}{{ end }} {{ if lt $diff $minDiff }} {{ $minDiff = $diff }} {{ $closestBook = . }} {{ end }} {{ end }} {{ $ratio := div (float $count) $closestBook.words }}相当于写了 {{ $ratio | printf "%.2f" }} 本《{{ $closestBook.name }}》。