syntra / gatsby-remark-reading-time

Gatsby remark plugin to add an estimated reading time field to all remark nodes
MIT License
25 stars 16 forks source link

Can we publish a new version to add MDX support #8

Closed tgallacher closed 4 years ago

tgallacher commented 4 years ago

It would be great to publish a new release, v1.1.0, to bring in MDX support (#5 and #7).

As mentioned before, I think this plugin offers additional value to the ecosystem even though the Gatsby MDX plugin provides the reading time natively. In my opinion this is because:

  1. The native gatsby mdx plugin offers less output options/formats than here
  2. including the readingTime field in the gatsby mdx plugin increases the query time considerably (tested on a site with 1k+ pages).
AriTheElk commented 4 years ago

Good info! I'm definitely open to merging a feature like that in :) I don't personally use mdx on any of my gatsby blogs though, so I'm unsure how to approach adding it.

I didn't find anything on npm for mdx reading time, I'm thinking we might have to fork the reading time plugin that this library uses. Keeping in-line with the performance needs, I'm unsure how to approach having an accurate reading time with mdx.

Using RegEx is definitely the easiest to add, but has performance implications when processing large content. Maybe we could use an mdx AST parser, like mdxast. That way we can skip everything that is jsx at the root level, without having to spend any time parsing it.

Let me know if you have any other ideas!

AriTheElk commented 4 years ago

I cut a new release with the mdx changes you added. I'm gonna close this issue and open up a new one for the changes I mentioned above.