Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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)