« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--package-lock.json12
-rw-r--r--package.json1
-rw-r--r--src/content/dependencies/generateCommentaryIndexPage.js9
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);