Replace reading-time
npm package by Intl.Segmenter
API
#11086
Labels
good first issue
If you are just getting started with Docusaurus, this issue should be a good place to begin.
help wanted
Asking for outside help and/or contributions to this particular issue or PR.
proposal
This issue is a proposal, usually non-trivial change
Have you read the Contributing Guidelines on issues?
Motivation
We could get rid of some npm lib/code in our blog
readingTime
API by relying on built-in Intl.Segmenter APIs (Node.js v16+)The library code is more complex, likely less performant, and less accurate (doesn't take the locale as param) than the native implementation
https://github.com/ngryman/reading-time/blob/master/src/reading-time.ts
This is not a critical feature but if someone from the community want to contribute, PRs welcome.
I'd appreciate if you start by writing unit tests / snapshots for the
reading-time
lib usage.Then we can see how the new implementation gives a different result depending on inputs.
Based on that result we can decide if it's safe to ship immediately, or if it requires a future flag + breaking change.
Note that Docusaurus exposes a way to pass your own readingTime function, and we may need to change that API: https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-blog#ReadingTimeFn
Self-service
The text was updated successfully, but these errors were encountered: