Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johanbrook/eleventy-plugin-reading-time
A non-dependency reading time plugin for Eleventy static site generator.
https://github.com/johanbrook/eleventy-plugin-reading-time
Last synced: 3 months ago
JSON representation
A non-dependency reading time plugin for Eleventy static site generator.
- Host: GitHub
- URL: https://github.com/johanbrook/eleventy-plugin-reading-time
- Owner: johanbrook
- Created: 2018-09-17T15:41:14.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-27T23:56:02.000Z (almost 3 years ago)
- Last Synced: 2024-10-07T23:10:57.903Z (3 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 25
- Watchers: 3
- Forks: 6
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Reading time plugin for Eleventy
A non-dependency reading time plugin for [Eleventy](https://www.11ty.io/) static site generator. This plugin provides a template tag which prints the number of minutes or seconds required to read the given text.
## Install
```shell
npm install --save eleventy-plugin-reading-time
```## Usage
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 }}
{{ content | safe }}
```
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 %}
```
## To Do
- [ ] Support more template engines.
## License
MIT.