Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

A Metalsmith plugin to estimate pages' reading times.

License

Notifications You must be signed in to change notification settings

emmercm/metalsmith-reading-time

Repository files navigation

metalsmith-reading-time

⚠️ This repistory has been moved to metalsmith-plugins. ⚠️

npm Version npm Weekly Downloads

Known Vulnerabilities Test Coverage Maintainability

GitHub License

A Metalsmith plugin to estimate pages' reading times.

Installation

npm install --save metalsmith-reading-time

JavaScript Usage

const Metalsmith  = require('metalsmith');
const readingTime = require('metalsmith-reading-time');

Metalsmith(__dirname)
    .use(readingTime({
        // options here
    }))
    .build((err) => {
        if (err) {
            throw err;
        }
    });

File metadata

This plugin adds a metadata field named readingTime to each file which can be used with templating engines, such as with handlebars:

Reading time: {{ readingTime }}

The rest of the page content.

Reading time will be reported in minutes in the form "# min read" per reading-time.

Options

pattern (optional)

Type: string Default: **/*

A micromatch glob pattern to find input files.

stripHtml (optional)

Type: boolean Default: true

Whether to strip HTML tags from content before evaluating the reading time or not.

replacements (optional)

type: (string|RegExp)[][] Default: []

A list of tuples fed to String.replace() to get rid of meaningless content before evaluating the reading time.

readingTime (optional)

Type: object Default: {}

An object of reading-time options, example:

{
  "readingTime": {
    "wordsPerMinute": 200
  }
}

Changelog

Changelog

About

A Metalsmith plugin to estimate pages' reading times.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages