{{ title }}
Add the reading time for a text as template tag.
npm install eleventy-plugin-reading-timeA 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.
``shell`
npm install --save eleventy-plugin-reading-time
In your Eleventy config file (defaults to .eleventy.js):
`js
const readingTime = require('eleventy-plugin-reading-time');
module.exports = (eleventyConfig) => {
eleventyConfig.addPlugin(readingTime);
};
`
Now you can use the readingTime filter in your Nunjuck templates:
`html`
About {{ someTextContent | readingTime } reading time}
prints
`html`
About 6 min reading time
Example post.njk template:
`html
{{ title }}
If you're in a collection loop, this filter accepts a collection object too:
`html
{% for post in posts %}
{{post.title}}
About {{ post | readingTime }} reading time.
{% endfor %}
``- [ ] Support more template engines.
MIT.