Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/myxotod/eleventy-plugin-readingtime
Lightweight 11ty plugin with no dependencies to display page/post reading time
https://github.com/myxotod/eleventy-plugin-readingtime
eleventy eleventy-plugin plugin reading reading-speed wordcount
Last synced: 20 days ago
JSON representation
Lightweight 11ty plugin with no dependencies to display page/post reading time
- Host: GitHub
- URL: https://github.com/myxotod/eleventy-plugin-readingtime
- Owner: MyXoToD
- License: mit
- Created: 2024-05-13T18:55:15.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-05-22T06:50:27.000Z (9 months ago)
- Last Synced: 2025-01-03T19:29:02.659Z (about 1 month ago)
- Topics: eleventy, eleventy-plugin, plugin, reading, reading-speed, wordcount
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@myxotod/eleventy-plugin-readingtime
- Size: 41 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# eleventy-plugin-readingtime
A lightweight [eleventy](https://11ty.dev) plugin to display page/post reading time in minutes. No dependencies.
![NPM Version](https://img.shields.io/npm/v/@myxotod/eleventy-plugin-readingtime.svg) ![NPM Downloads](https://img.shields.io/npm/d18m/%40myxotod%2Feleventy-plugin-readingtime) ![npm bundle size (scoped version)](https://img.shields.io/bundlephobia/min/%40myxotod/eleventy-plugin-readingtime/2.0.0)
## Usage
Install this package
```sh
npm i @myxotod/eleventy-plugin-readingtime
```Add and register it inside your `.eleventy.js` config file
```js
// .eleventy.js
const readingtime = require("@myxotod/eleventy-plugin-readingtime");module.exports = (eleventyConfig) => {
eleventyConfig.addPlugin(readingtime);
};
```Finally use it in your code with the `readingtime`-filter
```html
Reading time: {{ post | readingtime }}
```Example output
```html
Reading time: ~3min
```You will have to pass the whole post or page to the filter as shown above.
## Options
You can pass several options when adding the plugin in your eleventy config file like so:
```js
eleventyConfig.addPlugin(readingtime, {
wordsPerMinute: 200,
suffixDisplay: true,
suffixText: 'min',
prefixDisplay: true,
prefixText: '~',
verbose: false
});
```| Option | Default | Description |
|--------|---------|-------------|
|`wordsPerMinute`|`200`|Average number of words read per minute (higher values result in faster reading times)|
|`suffixDisplay`|`true`|Show or hide the suffix|
|`suffixText`|`'min'`|The suffix to be shown|
|`prefixDisplay`|`true`|Show or hide the prefix|
|`prefixText`|`'~'`|The prefix to be shown|
|`verbose`|`false`|Output additional data to your terminal when an eleventy build happens|## License
[MIT](https://github.com/MyXoToD/eleventy-plugin-readingtime/blob/main/LICENSE) @ [Maximilian Boll](https://www.makkusu.dev)