Reading time plugin for Eleventy
A non-dependency reading time plugin for Eleventy static site generator. This plugin provides a template tag which prints the number of minutes or seconds required to read the given text.
Install
npm install --save eleventy-plugin-reading-timeUsage
In your Eleventy config file (defaults to .eleventy.js):
const readingTime = ; module { eleventyConfig;};Now you can use the readingTime filter in your Nunjuck templates:
About {{ someTextContent | readingTime } reading time}prints
About 6 min reading timeExample post.njk template:
{{ title }} About {{ content | readingTime }} reading time {{ content | safe }} If you're in a collection loop, this filter accepts a collection object too:
{% for post in posts %} {{post.title}} About {{ post | readingTime }} reading time. {% endfor %}To Do
- Support more template engines.
License
MIT.