question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blog: accept custom reading time options

See original GitHub issue

🚀 Feature

I’m working on the reading-time library renovation, and I plan to add much more options than what are currently available. (e.g. different reading speeds for CJK and Latin languages) It would be cool if we can expose these options to the end users.

Have you read the Contributing Guidelines on issues?

Yes

Has this been requested on Canny?

No

Motivation

To make use of the customizability of reading-time—also, sometimes the default reading time is just not sensical enough.

API Design

A new plugin option readingTimeOptions which is directly passed to the readingTime function. Currently the options only include wordsPerMinute and wordBound, but there will be many more. cf https://github.com/ngryman/reading-time/pull/42#issuecomment-919900955

Have you tried building it?

No

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
Josh-Cenacommented, Oct 12, 2021

So you would have to “guess” the locale based on content?

“Guess” the language, sort of. The locale doesn’t really matter. I write some articles that are almost 50/50 Chinese and English. After all, it’s just about the word-counting algorithm, which should really be consistent across locales.

How does the lib (or callback) know the reading speed difference if we don’t provide it per language?

You provide multiple options: CJKCharactersPerMinute, LatinWordsPerMinute, CyrillicWordsPerMinute, etc.

Do you have a similar use-case for enhancing the default reading time?

I just feel like the default reading time function is already very usable, and we just need to inject additional options. Otherwise, the user would need to require readingTime every time, and… that’s unnecessary IMO

0reactions
slorbercommented, Oct 13, 2021

Yes, and maybe they want to tweak the options on a per-doc basis as well—we can support that by passing front matter into the callback. No problem.

Yes, that was my idea 😉 custom frontmatter could be used to tweak that algo

I prefer to keep it as number, at least for the callback (we can do the translation in the plugin). We don’t want the user to bear too much implementation burden.

👍

For the callback that makes sense but maybe we should allow providing a frontMatter readingTime as a string as well? Probably overkill, we can add that later if there’s an use-case

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Display Estimated Post Reading Time in Your ...
The easiest way to add estimated post-reading time is by using the Read Meter plugin. It's a free WordPress plugin that helps you...
Read more >
How to Display Estimated Reading Time in WordPress Blogs
Want to show customized estimated reading time in WordPress? PostX brings you this amazing opportunity right in your hand.
Read more >
How To Add Estimated Reading Time In Your WordPress Posts
Go to Settings -> Reading Time WP from the left sidebar panel. ... Once you are done, just go to Appearance -> Customize...
Read more >
How to Add An Estimated Post Reading Time To Your ...
In this article, we will show you two methods of adding an estimated post reading time to your WordPress posts. The first method...
Read more >
How to Display Estimated Post Reading Time in Blogger Posts?
You might know about Medium.com? Have you noticed one of its cool feature? - Estimated Post Reading Time! An estimated reading time encourages...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found