Skip to content

Commit

Permalink
fix: reading time in zh-cn
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamska1008 committed Jan 13, 2025
1 parent 087989e commit 83d60db
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion layouts/partials/article/components/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ <h3 class="article-subtitle">

{{ if $showReadingTime }}
<div>
{{ $readingTime := .ReadingTime }}
{{ if eq .Site.Language.LanguageCode "zh-cn"}}
{{ $wordsPerMinute := 500 }}
{{ $charCount := .Content | replaceRE "[\\pP]" "" | countrunes}}
{{ $readingTime = div (float $charCount) $wordsPerMinute | math.Ceil | int }}
{{ end }}
{{ partial "helper/icon" "clock" }}
<time class="article-time--reading">
{{ T "article.readingTime" .ReadingTime }}
{{ T "article.readingTime" $readingTime }}
</time>
</div>
{{ end }}
Expand Down

0 comments on commit 83d60db

Please sign in to comment.