Word count
Words a reader sees, and minutes to read them.
Markdownimport { countWords, readingMinutes } from "@humanonlyweb/writer";
const words = countWords(markdown);
readingMinutes(words); // at least 1, at 230 words a minuteCopy codecountWords(markdown) counts words, and readingMinutes(words, wordsPerMinute = 230) turns them into minutes.
It counts what a reader sees: link text but not URLs, and no images, code, block fences, attributes, footnote labels or frontmatter. Chinese and Japanese count a word per character.
It's synchronous, fast enough for every keystroke, and gives the same answer on the server and in the browser, so it's safe to render during SSR. In Nuxt it's auto-imported on the server too: store it with the document.