Skip to content

Commit 50bc711

Browse files
committed
fix: calculate actual read time and improve read time UI on blog cards
Fixes #1491 - Replaced hardcoded '5 min read' with dynamically calculated read time - Read time is calculated based on content length (200 words/min average) - Added clock emoji for better visual clarity - Applied to both blogCard component and blogs index page
1 parent 73512c6 commit 50bc711

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/components/blogCarousel/blogCard.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ const BlogCard = ({
134134
))}
135135
</div>
136136
</div>
137-
<span className="card-read-time">5 min read</span>
137+
<span className="card-read-time">
138+
🕒 {Math.max(1, Math.ceil(content.split(" ").length / 200))} min read
139+
</span>
138140
</div>
139141

140142
{/* Read More Button */}

src/pages/blogs/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,15 @@ const BlogCard = ({ blog }: { blog: (typeof blogs)[number] }) => {
335335
</div>
336336
</div>
337337

338-
{/* Read link */}
338+
{/* Read time + Read link */}
339+
<span className="card-read-time">
340+
🕒 {Math.max(1, Math.ceil((blog.description || "").split(" ").length / 200))} min read
341+
</span>
339342
<Link to={`/blog/${blog.slug}`} className="card-read-link">
340343
Read →
341344
</Link>
342345
</div>
343346
</div>
344347
</div>
345348
);
346-
};
349+
};

0 commit comments

Comments
 (0)