diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-10-21 18:10:27 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-10-21 18:31:34 -0300 |
commit | 6dfd5c6cabffbac8f8423d87bc761c928d9b5a54 (patch) | |
tree | 9b2f0e7b897169e1e97ac0213f963bfc07ad987f | |
parent | aa4b67362971b239e9c2d27a8bcdbb640c1059c8 (diff) |
content: generateCommentaryIndexPage: use npm word-count instead
-rw-r--r-- | package-lock.json | 12 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | src/content/dependencies/generateCommentaryIndexPage.js | 9 |
3 files changed, 20 insertions, 2 deletions
diff --git a/package-lock.json b/package-lock.json index 3a4d23b4..7cd27198 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "msgpackr": "1.11.1", "rimraf": "5.0.7", "striptags": "4.0.0-alpha.4", + "word-count": "0.3.1", "word-wrap": "1.2.5" }, "bin": { @@ -5862,6 +5863,12 @@ "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, + "node_modules/word-count": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/word-count/-/word-count-0.3.1.tgz", + "integrity": "sha512-tTDKyKX1yy8FZWUw64TOgnMeLeXPZBA+ZunaCCpFRrGFeLSwSdEgSsFI/5DIJkiUfM7CkCREFPkZd9U4eLXgqA==", + "license": "MIT" + }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", @@ -9949,6 +9956,11 @@ } } }, + "word-count": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/word-count/-/word-count-0.3.1.tgz", + "integrity": "sha512-tTDKyKX1yy8FZWUw64TOgnMeLeXPZBA+ZunaCCpFRrGFeLSwSdEgSsFI/5DIJkiUfM7CkCREFPkZd9U4eLXgqA==" + }, "word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", diff --git a/package.json b/package.json index c0567f31..bce87a58 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "msgpackr": "1.11.1", "rimraf": "5.0.7", "striptags": "4.0.0-alpha.4", + "word-count": "0.3.1", "word-wrap": "1.2.5" }, "license": "MIT", diff --git a/src/content/dependencies/generateCommentaryIndexPage.js b/src/content/dependencies/generateCommentaryIndexPage.js index 2dabffac..8cc30913 100644 --- a/src/content/dependencies/generateCommentaryIndexPage.js +++ b/src/content/dependencies/generateCommentaryIndexPage.js @@ -1,3 +1,5 @@ +import multilingualWordCount from 'word-count'; + import {sortChronologically} from '#sort'; import {accumulateSum, filterMultipleArrays, stitchArrays} from '#sugar'; @@ -48,11 +50,14 @@ export default { totalEntryCount: accumulateSum(query.entryCounts), }), - generate(data, relations, {html, defaultLanguage, language}) { + generate(data, relations, {html, language}) { const wordCounts = relations.albumBodies.map(bodies => accumulateSum(bodies, body => - defaultLanguage.countWords(body.slot('mode', 'multiline')))); + multilingualWordCount( + html.resolve( + body.slot('mode', 'multiline'), + {normalize: 'plain'})))); const totalWordCount = accumulateSum(wordCounts); |