Skip to content

Commit

Permalink
⚡ Perf: humanize total word count number (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Apr 28, 2022
1 parent 96d0fcc commit e0dc441
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@
{{- $localData.Add "totalWordCount" .WordCount -}}
{{- end -}}
{{- with ($localData.Get "totalWordCount") -}}
<span class="total-word-count footer-divider"><i class="far fa-keyboard fa-fw"></i>&nbsp;{{- T "totalwordCount" . -}}</span>
{{- $humanizedNum := . -}}
{{- if ge $humanizedNum 1000 -}}
{{- $humanizedNum = printf "%.2fK" (div $humanizedNum 1000.0) -}}
{{- end -}}
<span class="total-word-count footer-divider"><i class="far fa-keyboard fa-fw"></i>&nbsp;{{- T "totalwordCount" (dict "Count" $humanizedNum) -}}</span>
{{- end -}}
{{- end -}}
</div>
Expand Down

1 comment on commit e0dc441

@vercel
Copy link

@vercel vercel bot commented on e0dc441 Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.