Skip to content

fix: calculate actual read time and improve read time UI on blog cards#1544

Closed
aaniya22 wants to merge 6 commits into
recodehive:mainfrom
aaniya22:fix/blog-read-time-ui
Closed

fix: calculate actual read time and improve read time UI on blog cards#1544
aaniya22 wants to merge 6 commits into
recodehive:mainfrom
aaniya22:fix/blog-read-time-ui

Conversation

@aaniya22
Copy link
Copy Markdown
Contributor

Fixes #1491

Problem

Blog article cards were showing a hardcoded "5 min read" label
regardless of the actual article length, which was inaccurate
and had no visual styling.

Solution

  • Replaced hardcoded 5 min read with dynamically calculated
    read time based on content length (200 words per minute average)
  • Added 🕒 clock emoji for better visual clarity
  • Minimum read time is 1 min to avoid showing "0 min read"
  • Applied fix to both blogCard.tsx and blogs/index.tsx

Files Updated

  • src/components/blogCarousel/blogCard.tsx
  • src/pages/blogs/index.tsx

Fixes recodehive#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
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 17, 2026

@aaniya22 is attempting to deploy a commit to the recode Team on Vercel.

A member of the Team first needs to authorize it.

@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 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 17, 2026
@github-actions github-actions Bot added this to the recode:launch 3.0 milestone May 17, 2026
@github-actions github-actions Bot added Enhacement gssoc26 label gssoc:approved gssoc label level:beginner gssoc labels. 20pts type:design gssoc labels 10pts labels May 17, 2026
@github-actions
Copy link
Copy Markdown

✅ Synchronized metadata from Issue #1491:

  • Labels: level 1, recode, Enhacement, level:beginner, gssoc:approved, type:design
  • Milestone: recode:launch 3.0

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 17, 2026

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

Project Deployment Actions Updated (UTC)
recode-website Error Error May 18, 2026 2:02pm

@sanjay-kv
Copy link
Copy Markdown
Member

21:42:27.361 Running build in Washington, D.C., USA (East) – iad1
21:42:27.362 Build machine configuration: 4 cores, 8 GB
21:42:27.480 Cloning github.com/recodehive/recode-website (Branch: fix/blog-read-time-ui, Commit: 5313c88)
21:42:30.584 Cloning completed: 3.103s
21:42:30.740 Restored build cache from previous deployment (J7xzqR5KyRpf6d86ghfKPr7KFoNK)
21:42:30.962 Running "vercel build"
21:42:30.990 Vercel CLI 53.3.2
21:42:31.460 Warning: Due to "engines": { "node": ">=20.9.0" } in your `package.json` file, the Node.js Version defined in your Project Settings ("22.x") will not apply, Node.js Version "24.x" will be used instead. Learn More: https://vercel.link/node-version
21:42:31.461 Warning: Detected "engines": { "node": ">=20.9.0" } in your `package.json` that will automatically upgrade when a new major Node.js Version is released. Learn More: https://vercel.link/node-version
21:42:31.483 Installing dependencies...
21:42:34.275 
21:42:34.276 > recodehive@0.0.0 prepare
21:42:34.276 > husky
21:42:34.276 
21:42:34.339 
21:42:34.339 up to date in 3s
21:42:34.339 
21:42:34.339 563 packages are looking for funding
21:42:34.339   run `npm fund` for details
21:42:34.382 Running "npm run build"
21:42:34.480 
21:42:34.481 > recodehive@0.0.0 build
21:42:34.481 > docusaurus build
21:42:34.481 
21:42:35.698 ◇ injected env (0) from .env.local // tip: ⌘ override existing { override: true }
21:42:35.699 ◇ injected env (0) from .env // tip: ⌘ suppress logs { quiet: true }
21:42:35.717 [INFO] [en] Creating an optimized production build...
21:42:35.726 ◇ injected env (0) from .env.local // tip: ⌁ auth for agents [www.vestauth.com]
21:42:35.726 ◇ injected env (0) from .env // tip: ⌘ suppress logs { quiet: true }
21:42:36.923 [info] [webpackbar] Compiling Client
21:42:36.945 [info] [webpackbar] Compiling Server
21:42:46.372 [success] [webpackbar] Server: Compiled successfully in 9.43s
21:42:51.071 [success] [webpackbar] Client: Compiled successfully in 14.15s
21:43:00.349 
21:43:00.351 [ERROR] Error: Unable to build website for locale en.
21:43:00.352     at tryToBuildLocale (/vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:83:15)
21:43:00.352     at async /vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:35:9
21:43:00.353     ... 4 lines matching cause stack trace ...
21:43:00.353     at async file:///vercel/path0/node_modules/@docusaurus/core/bin/docusaurus.mjs:44:3 {
21:43:00.353   [cause]: Error: Docusaurus static site generation failed for 1 paths:
21:43:00.353   - "/blogs/"
21:43:00.353       at throwSSGError (/vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgGlobalResult.js:56:11)
21:43:00.353       at createGlobalSSGResult (/vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgGlobalResult.js:66:9)
21:43:00.353       ... 11 lines matching cause stack trace ...
21:43:00.353       at async file:///vercel/path0/node_modules/@docusaurus/core/bin/docusaurus.mjs:44:3 {
21:43:00.354     [cause]: AggregateError
21:43:00.354         at throwSSGError (/vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgGlobalResult.js:57:16)
21:43:00.354         at createGlobalSSGResult (/vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgGlobalResult.js:66:9)
21:43:00.354         at /vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgExecutor.js:30:68
21:43:00.354         at async executeSSG (/vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgExecutor.js:144:20)
21:43:00.354         at async buildLocale (/vercel/path0/node_modules/@docusaurus/core/lib/commands/build/buildLocale.js:84:31)
21:43:00.354         at async runBuildLocaleTask (/vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:98:5)
21:43:00.354         at async /vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:79:13
21:43:00.354         at async tryToBuildLocale (/vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:75:9)
21:43:00.354         at async /vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:35:9
21:43:00.354         at async mapAsyncSequential (/vercel/path0/node_modules/@docusaurus/utils/lib/jsUtils.js:21:24)
21:43:00.354         at async Command.build (/vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:34:5)
21:43:00.354         at async Promise.all (index 0)
21:43:00.354         at async runCLI (/vercel/path0/node_modules/@docusaurus/core/lib/commands/cli.js:56:5)
21:43:00.355         at async file:///vercel/path0/node_modules/@docusaurus/core/bin/docusaurus.mjs:44:3 {
21:43:00.355       [errors]: [
21:43:00.355         Error: Can't render static file for pathname "/blogs/"
21:43:00.355             at generateStaticFile (/vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgRenderer.js:131:20)
21:43:00.355             at processTicksAndRejections (node:internal/process/task_queues:104:5)
21:43:00.355             at runNextTicks (node:internal/process/task_queues:69:3)
21:43:00.355             at process.processImmediate (node:internal/timers:472:9)
21:43:00.355             at async /vercel/path0/node_modules/p-map/index.js:57:22 {
21:43:00.355           [cause]: ReferenceError: item is not defined
21:43:00.355               at BlogCard (server.bundle.js:52009:13194)
21:43:00.356               at Uc (server.bundle.js:20594:44)
21:43:00.356               at Xc (server.bundle.js:20596:253)
21:43:00.356               at Z (server.bundle.js:20602:89)
21:43:00.356               at Yc (server.bundle.js:20605:98)
21:43:00.356               at $c (server.bundle.js:20604:140)
21:43:00.356               at Z (server.bundle.js:20602:345)
21:43:00.356               at Yc (server.bundle.js:20605:98)
21:43:00.356               at Xc (server.bundle.js:20597:145)
21:43:00.356               at Z (server.bundle.js:20602:89)
21:43:00.356         }
21:43:00.356       ]
21:43:00.356     }
21:43:00.356   }
21:43:00.356 }
21:43:00.356 [INFO] Docusaurus version: 3.9.1
21:43:00.356 Node version: v24.15.0
21:43:00.441 Error: Command "npm run build" exited with 1

@aaniya22 it failed the deployent provided you the log

@Adez017
Copy link
Copy Markdown
Member

Adez017 commented May 18, 2026

@aaniya22 you can go with npm i and then npm run build to test your build working locally , once verify and tag any of @sanjay-kv @Adez017 to get it done

@Adez017 Adez017 self-requested a review May 18, 2026 05:05
@Adez017 Adez017 moved this to In Progress in @recode-web May 18, 2026
@Adez017 Adez017 moved this to Q2 2026 – March-June in Recode Public Roadmap May 18, 2026
@sanjay-kv
Copy link
Copy Markdown
Member

@aaniya22

21:42:27.361 Running build in Washington, D.C., USA (East) – iad1
21:42:27.362 Build machine configuration: 4 cores, 8 GB
21:42:27.480 Cloning github.com/recodehive/recode-website (Branch: fix/blog-read-time-ui, Commit: 5313c88)
21:42:30.584 Cloning completed: 3.103s
21:42:30.740 Restored build cache from previous deployment (J7xzqR5KyRpf6d86ghfKPr7KFoNK)
21:42:30.962 Running "vercel build"
21:42:30.990 Vercel CLI 53.3.2
21:42:31.460 Warning: Due to "engines": { "node": ">=20.9.0" } in your package.json file, the Node.js Version defined in your Project Settings ("22.x") will not apply, Node.js Version "24.x" will be used instead. Learn More: https://vercel.link/node-version
21:42:31.461 Warning: Detected "engines": { "node": ">=20.9.0" } in your package.json that will automatically upgrade when a new major Node.js Version is released. Learn More: https://vercel.link/node-version
21:42:31.483 Installing dependencies...
21:42:34.275
21:42:34.276 > recodehive@0.0.0 prepare
21:42:34.276 > husky
21:42:34.276
21:42:34.339
21:42:34.339 up to date in 3s
21:42:34.339
21:42:34.339 563 packages are looking for funding
21:42:34.339 run npm fund for details
21:42:34.382 Running "npm run build"
21:42:34.480
21:42:34.481 > recodehive@0.0.0 build
21:42:34.481 > docusaurus build
21:42:34.481
21:42:35.698 ◇ injected env (0) from .env.local // tip: ⌘ override existing { override: true }
21:42:35.699 ◇ injected env (0) from .env // tip: ⌘ suppress logs { quiet: true }
21:42:35.717 [INFO] [en] Creating an optimized production build...
21:42:35.726 ◇ injected env (0) from .env.local // tip: ⌁ auth for agents [www.vestauth.com]
21:42:35.726 ◇ injected env (0) from .env // tip: ⌘ suppress logs { quiet: true }
21:42:36.923 [info] [webpackbar] Compiling Client
21:42:36.945 [info] [webpackbar] Compiling Server
21:42:46.372 [success] [webpackbar] Server: Compiled successfully in 9.43s
21:42:51.071 [success] [webpackbar] Client: Compiled successfully in 14.15s
21:43:00.349
21:43:00.351 [ERROR] Error: Unable to build website for locale en.
21:43:00.352 at tryToBuildLocale (/vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:83:15)
21:43:00.352 at async /vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:35:9
21:43:00.353 ... 4 lines matching cause stack trace ...
21:43:00.353 at async file:///vercel/path0/node_modules/@docusaurus/core/bin/docusaurus.mjs:44:3 {
21:43:00.353 [cause]: Error: Docusaurus static site generation failed for 1 paths:
21:43:00.353 - "/blogs/"
21:43:00.353 at throwSSGError (/vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgGlobalResult.js:56:11)
21:43:00.353 at createGlobalSSGResult (/vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgGlobalResult.js:66:9)
21:43:00.353 ... 11 lines matching cause stack trace ...
21:43:00.353 at async file:///vercel/path0/node_modules/@docusaurus/core/bin/docusaurus.mjs:44:3 {
21:43:00.354 [cause]: AggregateError
21:43:00.354 at throwSSGError (/vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgGlobalResult.js:57:16)
21:43:00.354 at createGlobalSSGResult (/vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgGlobalResult.js:66:9)
21:43:00.354 at /vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgExecutor.js:30:68
21:43:00.354 at async executeSSG (/vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgExecutor.js:144:20)
21:43:00.354 at async buildLocale (/vercel/path0/node_modules/@docusaurus/core/lib/commands/build/buildLocale.js:84:31)
21:43:00.354 at async runBuildLocaleTask (/vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:98:5)
21:43:00.354 at async /vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:79:13
21:43:00.354 at async tryToBuildLocale (/vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:75:9)
21:43:00.354 at async /vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:35:9
21:43:00.354 at async mapAsyncSequential (/vercel/path0/node_modules/@docusaurus/utils/lib/jsUtils.js:21:24)
21:43:00.354 at async Command.build (/vercel/path0/node_modules/@docusaurus/core/lib/commands/build/build.js:34:5)
21:43:00.354 at async Promise.all (index 0)
21:43:00.354 at async runCLI (/vercel/path0/node_modules/@docusaurus/core/lib/commands/cli.js:56:5)
21:43:00.355 at async file:///vercel/path0/node_modules/@docusaurus/core/bin/docusaurus.mjs:44:3 {
21:43:00.355 [errors]: [
21:43:00.355 Error: Can't render static file for pathname "/blogs/"
21:43:00.355 at generateStaticFile (/vercel/path0/node_modules/@docusaurus/core/lib/ssg/ssgRenderer.js:131:20)
21:43:00.355 at processTicksAndRejections (node:internal/process/task_queues:104:5)
21:43:00.355 at runNextTicks (node:internal/process/task_queues:69:3)
21:43:00.355 at process.processImmediate (node:internal/timers:472:9)
21:43:00.355 at async /vercel/path0/node_modules/p-map/index.js:57:22 {
21:43:00.355 [cause]: ReferenceError: item is not defined
21:43:00.355 at BlogCard (server.bundle.js:52009:13194)
21:43:00.356 at Uc (server.bundle.js:20594:44)
21:43:00.356 at Xc (server.bundle.js:20596:253)
21:43:00.356 at Z (server.bundle.js:20602:89)
21:43:00.356 at Yc (server.bundle.js:20605:98)
21:43:00.356 at $c (server.bundle.js:20604:140)
21:43:00.356 at Z (server.bundle.js:20602:345)
21:43:00.356 at Yc (server.bundle.js:20605:98)
21:43:00.356 at Xc (server.bundle.js:20597:145)
21:43:00.356 at Z (server.bundle.js:20602:89)
21:43:00.356 }
21:43:00.356 ]
21:43:00.356 }
21:43:00.356 }
21:43:00.356 }
21:43:00.356 [INFO] Docusaurus version: 3.9.1
21:43:00.356 Node version: v24.15.0
21:43:00.441 Error: Command "npm run build" exited with 1

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates blog listing cards to show a computed “min read” label instead of a hardcoded “5 min read”, and adds a clock indicator to improve clarity on the blog card UI.

Changes:

  • Replace the hardcoded read-time label with a calculated value (200 words/min, minimum 1 minute).
  • Add a clock indicator alongside the read-time text on blog cards.
  • Apply the update in both the main blogs list and the blog carousel card.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/pages/blogs/index.tsx Replaces the hardcoded read-time label in the blogs listing card with a computed value (currently references an undefined item / missing content).
src/components/blogCarousel/blogCard.tsx Replaces the hardcoded read-time label in the carousel card with a computed value based on the provided content prop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/pages/blogs/index.tsx Outdated
</div>
<span className="card-read-time">5 min read</span>
<span className="card-read-time">
🕒 {Math.max(1, Math.ceil(content.split(" ").length / 200))} min read
Comment on lines +137 to +139
<span className="card-read-time">
🕒 {Math.max(1, Math.ceil(content.split(" ").length / 200))} min read
</span>
Comment thread src/pages/blogs/index.tsx Outdated
Comment on lines +343 to +344
🕒 {Math.max(1, Math.ceil((item.content || "").split(" ").length / 200))} min read
</span>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

✅ Synchronized metadata from Issue #1491:

  • Labels: level 1, recode, Enhacement, level:beginner, gssoc:approved, type:design
  • Milestone: recode:launch 3.0

@Adez017
Copy link
Copy Markdown
Member

Adez017 commented May 18, 2026

@aaniya22 can you look into the build error

@sanjay-kv
Copy link
Copy Markdown
Member

sanjay-kv commented May 18, 2026

This is the vercel preview and the main page crashes @aaniya22 @Adez017
https://recode-website-8vv5h3khy-recode-9c2fd7df.vercel.app/

  • didnt see the read time changes on blog

@Adez017
Copy link
Copy Markdown
Member

Adez017 commented May 18, 2026

This is the vercel preview and the main page crashes @aaniya22 @Adez017 https://recode-website-8vv5h3khy-recode-9c2fd7df.vercel.app/

  • didnt see the read time changes on blog

preview not available although i there's some bug with our package file local build also failing @sanjay-kv

@Adez017
Copy link
Copy Markdown
Member

Adez017 commented May 18, 2026

Will try to resolve again there's some version mismatch

@github-actions
Copy link
Copy Markdown

✅ Synchronized metadata from Issue #1491:

  • Labels: level 1, recode, Enhacement, level:beginner, gssoc:approved, type:design
  • Milestone: recode:launch 3.0

@github-actions
Copy link
Copy Markdown

✅ Synchronized metadata from Issue #1491:

  • Labels: level 1, recode, Enhacement, level:beginner, gssoc:approved, type:design
  • Milestone: recode:launch 3.0

@sanjay-kv
Copy link
Copy Markdown
Member

#1546 caused the vercel deployment fail again, lets focus 1:1 PR: Issue

@github-actions
Copy link
Copy Markdown

✅ Synchronized metadata from Issue #1491:

  • Labels: level 1, recode, Enhacement, level:beginner, gssoc:approved, type:design
  • Milestone: recode:launch 3.0

@Adez017
Copy link
Copy Markdown
Member

Adez017 commented May 19, 2026

@aaniya22 can you open a fresh PR with the changes ? This PR is failing on vercel CI and the errors are uncertain .
CC: @sanjay-kv

@aaniya22
Copy link
Copy Markdown
Contributor Author

@aaniya22 can you open a fresh PR with the changes ? This PR is failing on vercel CI and the errors are uncertain .

CC: @sanjay-kv

ok, will do it

@aaniya22
Copy link
Copy Markdown
Contributor Author

@Adez017 @sanjay-kv opened the fresh PR as requested: #1668

Branch has been rebased on latest main, no conflicts, and lint is passing. The only pending item is Vercel authorization which requires maintainer approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhacement gssoc26 label gssoc:approved gssoc label in-review The current changes are in review and would need approval and testing before merging level:beginner gssoc labels. 20pts level 1 10 points recode this is label for leaderboard type:design gssoc labels 10pts

Projects

Status: Done
Status: Q2 2026 – March-June

Development

Successfully merging this pull request may close these issues.

Blog article read time change UI

4 participants