File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -17,12 +17,13 @@ const stripHtml = async (text: string) => {
17
17
*
18
18
* Calculates the reading time of a ReactNode in minutes
19
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" )
20
+ export const calculateReadtime = async ( node : ReactNode , wpm : number = 160 ) : Promise < number > => {
21
+ if ( isBrowser ) throw Error ( "calculateReadtime can only be used on the server" ) ;
22
22
const { reactNodeToString } = await import ( "./react" ) ;
23
23
24
24
const content = await stripHtml ( await reactNodeToString ( node ) ) ;
25
25
const words = content . split ( / [ \s ] + / ) ;
26
+
26
27
return Math . round ( words . length / wpm ) ;
27
28
} ;
28
29
You can’t perform that action at this time.
0 commit comments