Skip to content

Correct reading time calculation to avoid systematic overestimation #33

@plx

Description

@plx

Summary

readingTime currently adds an unconditional +1 minute before rounding, resulting in systematic overestimation.

Affected files:

  • src/lib/utils.ts
  • src/pages/blog/[...slug].astro
  • src/pages/projects/[...slug].astro

Why This Matters

Displayed reading time is user-facing metadata and should be approximately accurate.

Proposed Strategy

  • Update reading time formula to standard behavior: max(1, ceil(wordCount / 200)).
  • Optionally normalize empty/very short content to 1 min read.
  • Add focused unit tests for representative word counts (0, 1, 199, 200, 201, 399, 400).

Done Criteria / Validation

  • readingTime no longer adds a blanket extra minute.
  • Added tests cover edge cases and pass.
  • npm run build passes.
  • Sample long/short posts display expected values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:mediumImportant but not urgent

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions