We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0fbdfc6 commit c0a9f1cCopy full SHA for c0a9f1c
1 file changed
src/utils/readtime.ts
@@ -17,12 +17,13 @@ const stripHtml = async (text: string) => {
17
*
18
* Calculates the reading time of a ReactNode in minutes
19
*/
20
-export const calculateReadtime = async (node: ReactNode, wpm: number = 200): Promise<number> => {
21
- if (isBrowser) throw Error("calculateReadtime can only be used on the server")
+export const calculateReadtime = async (node: ReactNode, wpm: number = 160): Promise<number> => {
+ if (isBrowser) throw Error("calculateReadtime can only be used on the server");
22
const { reactNodeToString } = await import("./react");
23
24
const content = await stripHtml(await reactNodeToString(node));
25
const words = content.split(/[\s]+/);
26
+
27
return Math.round(words.length / wpm);
28
};
29
0 commit comments