Artwork by Katerina Limpitsouni

gatsby-plugin-reading-time-2

A Gatsby plugin to estimate your markdown files reading time.

This plugin is sort of a fork from gatsby-remark-reading-time updated and with added configuration.

✨ Features

  • Medium like reading time estimation (based on reading-time).
  • Compatible with Mdx and MarkdownRemark.
  • Configurable.

⚙️ Installing

For Yarn users:

yarn add gatsby-plugin-reading-time-2

For Npm users:

npm install gatsby-plugin-reading-time-2

🚀 Usage

With Mdx

Add gatsby-plugin-reading-time-2 as a plugin in gatsby-config.js:

module.exports ={
  plugins: [
    // ...
    `gatsby-plugin-reading-time-2`,
    // ...
  ],
}

With MarkdownRemark

Add gatsby-plugin-reading-time-2 as a MarkdownRemark plugin in gatsby-config.js:

module.exports ={
  plugins: [
    // ...
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          // ...
          `gatsby-plugin-reading-time-2`,
          //... 
        ]
      }
    },
    // ...
  ],
}

🔧 Configuration

This plugin accepts 2 options following reading-time options:

  • options.wordsPerMinute: the words per minute an average reader can read (default: 200).
  • options.wordBound: a function that returns a boolean value depending on if a character is considered as a word bound (default: spaces, new lines and tabs).

Resolve the plugin as follows to use them:

{
  resolve: `gatsby-plugin-reading-time-2`,
  options: {
    wordsPerMinute: 200,
    wordBound: function(c) { return ' \n\r\t'.includes(c) },
  }
}

🤝 Contributing

Any contribution to the project is welome.
Run into a problem? Open an issue.
Want to add some feature? PRs are welcome!

📝 Licence

Copyright © 2021 Sacha Bouillez.
This project is under MIT license.