mtownsend5512 / read-time Goto Github PK
View Code? Open in Web Editor NEWA PHP package to show users how long it takes to read content.
License: MIT License
A PHP package to show users how long it takes to read content.
License: MIT License
Not supporting the encoding utf-8 as I am indeed of it badly. any help?
Using this package with a cached config (php artisan config:cache
) & using the default config from the package throws the following error:
Argument 1 passed to Mtownsend\ReadTime\ReadTime::omitSeconds() must be of the type bool, null given, called in vendor/mtownsend/read-time/src/Providers/ReadTimeServiceProvider.php on line 54
I think this is due to the config being loaded in the binding. I think the mergeConfigFrom
should be in the boot method of the service provider.
If possible, would you mind submitting the PR to integrate the GitHub action?
@mtownsend5512 Do you recall if there is a reason that the minutes calculation is set to 1 if it is < 1?
There are times when a short article will have a less than a minute read time. If displaying both minutes and seconds from the estimation, it incorrectly displays as something like "1 minute 45 second read time" instead of "45 second read time".
First off, thanks for your work here. This is one of those useful little libraries that is just Such A Good Idea™
Now, on to other matters... I think there may be an error in the calculation when it comes to very large bodies of text. In the first example (at about 4.5k words, including code); it calculates the length of time as 15 minutes.
In the second example (at about 6.5k words, including code); it calculates the length of time as 4 minutes.
Check the size of the scroller, or the lengths of the posts on the site. You can also check out where I am using it, on Github.
Hi
Thank you for your work.
I've encountered a problem with function type-hints bool which can be nullable.
Argument 1 passed to Mtownsend\ReadTime\ReadTime::timeOnly() must be of the type boolean, null given
I could develop a fix, but the language level needs to raise to php 7.1.x
Is this an option?
Thank you and have a nice day
Error is:
Argument 1 passed to Mtownsend\ReadTime\ReadTime::setTranslation() must be of the type array, string given
Using it like
read_time([
'content' => $post->content,
])
Tried without array as well
read_time($post->content)
Success when used with
read_time([
'content' => $post->content,
'translation' => [
'reads_left_to_right' => true,
'min' => 'min',
'minute' => 'minute',
'sec' => 'sec',
'second' => 'second',
'read' => 'read'
]
])
Although writing translations works too, it might be easy to have an option to get a DateInterval from the class.
Then we can use our own handlers to format it, or do stuff like "you'll finish this by [time]".
I could work on this, but wouldn't want to add functionality that's unwanted, so let me know.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.