Skip to content

🎥 Make videos programmatically with React

add word count to documentation

Jonny Burgerebe086d726d3
diff --git a/packages/docs/count-pages.mjs b/packages/docs/count-pages.mjs
index 114dd79ac7..58a5367ef8 100644
--- a/packages/docs/count-pages.mjs
+++ b/packages/docs/count-pages.mjs
@@ -1,3 +1,4 @@
+import { readFileSync } from "fs";
import path from "path";
import { readDir } from "./get-pages.mjs";
@@ -5,4 +6,17 @@ const root = path.join(process.cwd(), "docs");
const pages = readDir(root);
-console.log(`There are ${pages.length} documentation pages.`);
+let words = 0;
+
+for (const page of pages) {
+ const contents = readFileSync(page);
+ const wordCount = contents
+ .toString()
+ .split("\n")
+ .map((s) => s.split(" "))
+ .flat(1)
+ .filter(Boolean).length;
+ words += wordCount;
+}
+
+console.log(`There are ${pages.length} documentation pages. Words: ${words}`);