Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(blog): ignore hidden code blocks when calculating read time #9302

Merged
merged 1 commit into from
Jul 14, 2023

Conversation

LeoMcA
Copy link
Member

@LeoMcA LeoMcA commented Jul 14, 2023

Summary

Problem

Hidden code blocks were being included in the read time calculation for blog posts, which leads to https://developer.mozilla.org/en-US/blog/scroll-progress-animations-in-css/ for instance having a 25 minute read time, because of lots of lorem ipsum being included in the examples.

Solution

Ignore hidden code blocks when doing this calculation: the above article now has a 7 minute read time.


How did you test this change?

  • yarn dev, visited article locally
  • also pasted source of article into https://regex101.com/ and checked my regex matched the intended blocks (and nothing else - I needed that non-greedy match ?)

@LeoMcA LeoMcA requested a review from bsmth July 14, 2023 12:01
Copy link
Member

@bsmth bsmth left a comment

Choose a reason for hiding this comment

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

Thanks, Leo - looks good to me 👍🏻

image

@LeoMcA LeoMcA merged commit 9f237bd into main Jul 14, 2023
@LeoMcA LeoMcA deleted the read-time-ignore-hidden branch July 14, 2023 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants