awilum / craft-reading-time
Reading Time plugin shows the estimated reading time of the content, in seconds or minutes.
Fund package maintenance!
awilum.github.io/donate
Installs: 404
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 0
Type:craft-plugin
Requires
- craftcms/cms: ^4.3.3
Requires (Dev)
- ext-iconv: *
- pestphp/pest: ^1.22
- phpstan/phpstan: ^1.8.0
This package is auto-updated.
Last update: 2024-11-13 16:38:27 UTC
README
Reading Time plugin shows the estimated reading time of the content, in seconds or minutes.
Requirements
- Craft CMS: ^4.0
- PHP: ^8.0
Installation
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
In your terminal run
composer require awilum/craft-reading-time
. -
In the Control Panel, go to Settings → Plugins and click the “Install” button for Reading Time.
Usage
Display reading time in the twig templates:
{{ readingTime('Some text here ...') }}
Display reading time with custom translates in the twig templates:
{{ readingTime('Some text here ...', {
'minute': 'Minute',
'minutes': 'Minutes',
'second': 'Second',
'seconds': 'Seconds'
}) }}
Display reading time with custom translates and format in the twig templates:
{{ readingTime('Some text here ...', {
'minute': 'Minute',
'minutes': 'Minutes',
'second': 'Second',
'seconds': 'Seconds',
'format': '[minutes_count] [minutes_label] – [seconds_count] [seconds_label]'
}) }}
Display reading time with custom translates and format that with alternative format that hides the minutes
and seconds
label in the twig templates
{{ readingTime('Some text here ...', {
'minute': 'Minute',
'minutes': 'Minutes',
'second': 'Second',
'seconds': 'Seconds',
'format': '[minutes_count] [minutes_label] – [seconds_count] [seconds_label]'
}) }}
Also you can use readingTime
filter in your twig templates:
{{ 'Some text here ...'|readingTime }}
Use readingTime
function in the PHP:
use function Awilum\CraftReadingTime\readingTime; echo readingTime('Some text here ...');
LICENSE
The MIT License (MIT) Copyright (c) Sergey Romanenko