Skip to content
Gatsby WordPress plugin for adding a reading time estimation
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.babelrc
.eslintrc
.gitignore
.npmignore
.prettierrc
.travis.yml
LICENSE
README.md
index.js
package-lock.json
package.json

README.md

Build Status Vulnerabilities codecov Dependencies npm version

gatsby-wordpress-reading-time

Gatsby WordPress plugin for adding a reading time estimation, like Medium does. This library uses reading-time behind the screens.

Install

This plugin can be installed by using:

npm install --save gatsby-wordpress-reading-time

How to use

This plugin should be applied on gatsby-source-wordpress. For example:

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-wordpress`,
      options: {
        // Other options ...
        plugins: [
          `gatsby-wordpress-reading-time`,
        ]
      }
    },
  ]
};

How to query

When configured, this plugin will add a readingTime field for every WordPress entity that contains a content field. This means that posts, pages and custom post types should all be supported.

The following query can be used to obtain the reading time estimation for all WordPress posts:

{
  allWordpressPost {
    edges {
      node {
        fields {
          readingTime {
            text
            minutes
            time
            words
          }
        }
      }
    }
  }
}

The structure of the readingTime field is the same as the structure provided by the reading-time library.

Examples

The following repository contains an example of a Gatsby blog using the gatsby-wordpress-reading-time plugin:

License

MIT

License status

FOSSA Status

You can’t perform that action at this time.