@@ -17,6 +17,7 @@ import Seo from '../components/Seo';
1717import ShareButtons from '../components/ShareButtons' ;
1818import remarkGfm from 'remark-gfm' ;
1919import rehypeRaw from 'rehype-raw' ;
20+ import { calculateReadingTime } from '../utils/readingTime' ;
2021
2122const LinkRenderer = ( { href, children } ) => {
2223 const isExternal = href . startsWith ( 'http' ) || href . startsWith ( 'https' ) ;
@@ -131,6 +132,7 @@ const BlogPostPage = () => {
131132 const [ post , setPost ] = useState ( null ) ;
132133 const [ loading , setLoading ] = useState ( true ) ;
133134 const [ readingProgress , setReadingProgress ] = useState ( 0 ) ;
135+ const [ estimatedReadingTime , setEstimatedReadingTime ] = useState ( 0 ) ;
134136 const [ isAtTop , setIsAtTop ] = useState ( true ) ; // New state for tracking if at top
135137 const contentRef = useRef ( null ) ;
136138 const [ isModalOpen , setIsModalToOpen ] = useState ( false ) ;
@@ -241,6 +243,7 @@ const BlogPostPage = () => {
241243 seriesPosts,
242244 currentSeries,
243245 } ) ;
246+ setEstimatedReadingTime ( calculateReadingTime ( postBody ) ) ;
244247 } catch ( error ) {
245248 console . error ( 'Error fetching post or metadata:' , error ) ;
246249
@@ -421,6 +424,7 @@ const BlogPostPage = () => {
421424 overrideDate = { post . attributes . date }
422425 updatedDate = { post . attributes . updated }
423426 seriesPosts = { post . seriesPosts }
427+ estimatedReadingTime = { estimatedReadingTime }
424428 />
425429 </ div >
426430 </ div >
0 commit comments