2.0.0 • Published 1 year ago

@myxotod/eleventy-plugin-readingtime v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

eleventy-plugin-readingtime

A lightweight eleventy plugin to display page/post reading time in minutes. No dependencies.

NPM Version NPM Downloads npm bundle size (scoped version)

Usage

Install this package

npm i @myxotod/eleventy-plugin-readingtime

Add and register it inside your .eleventy.js config file

// .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

<div>Reading time: {{ post | readingtime }}</div>

Example output

<div>Reading time: ~3min</div>

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:

eleventyConfig.addPlugin(readingtime, {
  wordsPerMinute: 200,
  suffixDisplay: true,
  suffixText: 'min',
  prefixDisplay: true,
  prefixText: '~',
  verbose: false
});
OptionDefaultDescription
wordsPerMinute200Average number of words read per minute (higher values result in faster reading times)
suffixDisplaytrueShow or hide the suffix
suffixText'min'The suffix to be shown
prefixDisplaytrueShow or hide the prefix
prefixText'~'The prefix to be shown
verbosefalseOutput additional data to your terminal when an eleventy build happens

License

MIT @ Maximilian Boll

2.0.0

1 year ago

1.1.2

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago