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

[gatsby-plugin-mdx] timeToRead returns NaN if wordCount in Mdx component is 0 #30490

Closed
JobenM opened this issue Mar 26, 2021 · 1 comment
Closed
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@JobenM
Copy link
Contributor

JobenM commented Mar 26, 2021

Description

It's possible to have an mdx components without words for example we sometimes have embedded videos/ youtube.

So in this use case the getCounts function returns words property of undefined because the AST visitor never hits a word/paragraph. Thus the calculation for timeToRead (Math.round(words / avgWPM)) returns NaN.

I propose we fallback to 0 for these properties returned in getCounts and then timeToRead can default to 1.

Potential Fix

#30489

@JobenM JobenM added the type: bug An issue or pull request relating to a bug in Gatsby label Mar 26, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Mar 26, 2021
@vladar vladar added topic: MDX and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Mar 26, 2021
@vladar
Copy link
Contributor

vladar commented Mar 26, 2021

Thank you for the report and PR! 👍 I am closing this issue now that the PR is merged.

@vladar vladar closed this as completed Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

2 participants