Skip to content

feat: Add reading time to blog listing cards (#1766)#1824

Merged
sanjay-kv merged 2 commits into
recodehive:mainfrom
ida-jemi:feat/reading-time-blog-cards
Jun 2, 2026
Merged

feat: Add reading time to blog listing cards (#1766)#1824
sanjay-kv merged 2 commits into
recodehive:mainfrom
ida-jemi:feat/reading-time-blog-cards

Conversation

@ida-jemi
Copy link
Copy Markdown
Contributor

Description

Fixes # 1766

Type of Change

  • New feature (e.g., new page, component, or functionality)
  • Bug fix (non-breaking change that fixes an issue)
  • UI/UX improvement (design, layout, or styling updates)
  • Performance optimization (e.g., code splitting, caching)
  • Documentation update (README, contribution guidelines, etc.)
  • Other (please specify):

Changes Made

  • Added Reading Time field to all blog entries in src/database/blogs/index.tsx, calculated from the actual MDX source files using the same words / 200 formula that Docusaurus uses internally
  • Fixed src/pages/blogs/index.tsx - BlogCard was using usePluginData("blog-reading-time-plugin") which doesn't exist, causing it to always fall back to 1 min read. Now reads from blog.readingTime directly
  • Fixed src/components/blogCarousel/blogCard.tsx - removed the usePluginData lookup and replaced with readingTime ?? 1
  • Fixed src/components/blogCarousel/blogCarousel.tsx - was passing read time calculated from the short description excerpt instead of the stored value
  • Fixed src/components/BlogSearch/index.tsx - replaced hardcoded 5 min read with actual readingTime from the blog database
image

Dependencies

  • No new dependencies added.

Checklist

  • My code follows the style guidelines of this project.
  • I have tested my changes across major browsers and devices
  • My changes do not generate new console warnings or errors .
  • I ran npm run build and attached screenshot(s) in this PR.
  • This is already assigned Issue to me, not an unassigned issue.

** npm run build crashes locally due to a GLib/Windows environment issue unrelated to these changes. Verified all changes work correctly via npm start - blog cards on /blogs page, carousel, and search all display correct read times.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 31, 2026

@ida-jemi is attempting to deploy a commit to the recode Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added in-review The current changes are in review and would need approval and testing before merging level 1 10 points recode this is label for leaderboard labels May 31, 2026
@github-actions
Copy link
Copy Markdown

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. The estimated time for response is 5–8 hrs.

In the meantime, please provide all necessary screenshots and make sure you run - npm build run , command and provide a screenshot, a video recording, or an image of the update you made below, which helps speed up the review and assignment. If you have questions, reach out to LinkedIn. Your contributions are highly appreciated!😊

Note: I maintain the repo issue every day twice at 8:00 AM IST and 9:00 PM IST. If your PR goes stale for more than one day, you can tag and comment on this same issue by tagging @sanjay-kv.

We are here to help you on this journey of open source. Consistent 20 contributions are eligible for sponsorship 💰

🎁 check our list of amazing people we sponsored so far: GitHub Sponsorship. ✨

📚Your perks for contribution to this community 👇🏻

  1. Get free Consultation use code recode50 to get free: Mentorship for free.

  2. Get the Ebook for free use code recode at checkout: Data Science cheatsheet for Beginners.

  3. Check out this weekly Newsletter: Sanjay's Newsletter.

If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊

@github-actions github-actions Bot added this to the recode:launch 3.0 milestone May 31, 2026
@github-actions github-actions Bot added Enhacement gssoc26 label enhancement New feature or request gssoc:approved gssoc label labels May 31, 2026
@github-actions
Copy link
Copy Markdown

✅ Synchronized metadata from Issue #1766:

  • Labels: enhancement, level 1, recode, Enhacement, gssoc:approved
  • Milestone: None

@Karanjot786

This comment has been minimized.

@Adez017 Adez017 requested review from Adez017 and sanjay-kv and removed request for sanjay-kv June 1, 2026 05:00
Copy link
Copy Markdown
Member

@Adez017 Adez017 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this much file changes required for the issue assigned on this task .
CC: @sanjay-kv @iitzIrFan

Copy link
Copy Markdown
Member

@iitzIrFan iitzIrFan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ida-jemi , could you add some context on the implementation here? From a quick look, it seems the logic was initially made dynamic but later hardcoded. A short explanation of the approach and the reasoning behind it would help reviewers and maintainers understand the changes better. Thanks!

@iitzIrFan iitzIrFan added the don't-merge faced conflict issue or other dev related issue, dont merge PR label Jun 1, 2026
@ida-jemi ida-jemi requested a review from iitzIrFan June 1, 2026 08:55
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

✅ Synchronized metadata from Issue #1766:

  • Labels: enhancement, level 1, recode, Enhacement, gssoc:approved
  • Milestone: None

@ida-jemi
Copy link
Copy Markdown
Contributor Author

ida-jemi commented Jun 1, 2026

@ida-jemi , could you add some context on the implementation here? From a quick look, it seems the logic was initially made dynamic but later hardcoded. A short explanation of the approach and the reasoning behind it would help reviewers and maintainers understand the changes better. Thanks!

Hi @iitzIrFan! The readingTime values in index.tsx are manually calculated by reading each blog post, not arbitrary numbers. This project already stores all blog metadata statically in index.tsx (title, description, authors, tags), so adding readingTime there follows the same existing pattern.
There's no Docusaurus plugin active in this project that could calculate it dynamically, so static values in the database felt like the most consistent approach.
I'm completely open to a better approach if you have one in mind. Thanks for the feedback!

@ida-jemi
Copy link
Copy Markdown
Contributor Author

ida-jemi commented Jun 1, 2026

I am not sure this much file changes required for the issue assigned on this task .
CC: @sanjay-kv @iitzIrFan

Hi @Adez017, I've cleaned up the PR, removed the unused plugin files and the unrelated BlogPostItem/Header change.
The PR now only touches 7 files, each necessary for a specific reason:

  • src/database/blogs/index.tsx - adds the readingTime field to each blog entry
  • src/pages/blogs/index.tsx - displays reading time on the blog listing cards (this is the core of the feature)
  • src/pages/blogs/blogs-new.css - styles for the reading time badge on the listing page
  • src/components/blogCarousel/blogCard.tsx - displays reading time on carousel cards (carousel is also a blog listing surface)
  • src/components/blogCarousel/blogCarousel.tsx - passes the readingTime prop down to the card component
  • src/components/blogCarousel/blogCarousel.css - styles for the reading time badge in the carousel
  • docusaurus.config.ts - cleanup only (removing the unused plugin import)

The reason it touches both the blog listing page and the carousel is that both are places where blog cards are displayed to users, so both need to show reading time for consistency.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jun 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
recode-website Ready Ready Preview, Comment Jun 2, 2026 11:58am

@sanjay-kv sanjay-kv merged commit fe998f7 into recodehive:main Jun 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

don't-merge faced conflict issue or other dev related issue, dont merge PR Enhacement gssoc26 label enhancement New feature or request gssoc:approved gssoc label in-review The current changes are in review and would need approval and testing before merging level 1 10 points recode this is label for leaderboard

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants