Home Projects Portfolio Dashboard Export PDF Log in

Enhancing Content UX: Implementing Automated Read Time Calculations

Adding Value for Readers

In our ongoing work on the Blog-Server project, we recently tackled a small but impactful feature: automatically calculating and displaying the estimated reading time for each post.

Content consumption is a trade-off between depth and time. By providing a clear expectation of the time investment required, we empower our users to better manage their reading schedule, directly improving the overall user experience.

The Technical Approach

Within our Hexagonal Architecture, we approach this by decoupling the business logic of content estimation from our REST API delivery layer. We want to ensure that whenever a post is updated or created, the system calculates this metadata without polluting our core domain models.

Using TypeScript, we implement a simple service that estimates reading speed based on a standard average (typically 200-250 words per minute).

export const calculateReadTime = (content: string): number => {
  const wordsPerMinute = 225;
  const wordCount = content.trim().split(/\s+/).length;
  return Math.ceil(wordCount / wordsPerMinute);
};

By integrating this utility into our content creation workflow, we ensure that the "read time" is treated as a first-class citizen in our data structure. When the API returns a post, the consumer receives the estimated time alongside the content body, making frontend integration trivial.

Lessons Learned

  1. Keep it Pluggable: By isolating the calculation logic, we can easily tweak the words-per-minute threshold later if our audience's reading habits change, without touching the database or API routing logic.
  2. Consistency Matters: Ensure that the calculation is consistent across both the CMS and the public-facing API. Calculating it at the service layer ensures that regardless of who requests the data, the estimate remains uniform.

Takeaway

Small metadata enhancements, like read time, significantly improve user clarity. Next time you work on a content-heavy service, identify if you can pre-calculate helpful UI hints in your domain layer—your frontend developers will thank you for the extra context.


Generated with Gitvlg.com

Enhancing Content UX: Implementing Automated Read Time Calculations
LAUTARO NICOLAS ZULETA

LAUTARO NICOLAS ZULETA

Author

Share: