Skip to content

Commit

Permalink
Fixed incorrect sum of site word count. (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyxguo committed Apr 4, 2021
1 parent 0028116 commit 0f48b3f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scripts/lib/helpers/symbols-count-time.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ function symbolsCountTime(content, isSite) {
var getSymbolsTotal = function (posts) {
var symbolsResultCount = 0
posts.forEach(function (post) {
symbolsResultCount += Number(
String(post.count_time.symbolsCount).replace(/[k]+/g, '000')
)
if (String(post.count_time.symbolsCount).indexOf('k') > -1) {
post.count_time.symbolsCount =
Number(String(post.count_time.symbolsCount).replace(/[k]+/g, '')) *
1000
}
symbolsResultCount += Number(post.count_time.symbolsCount)
})
if (symbolsResultCount > 9999) {
symbolsResultCount = Math.round(symbolsResultCount / 1000) + 'k' // > 9999 => 11k
Expand Down

0 comments on commit 0f48b3f

Please sign in to comment.