A Gatsby plugin to calculate the estimated reading time for Contentful Rich Text fields and add it as a field in your Gatsby GraphQL schema.
To use this plugin in your Gatsby project, install it using:
npm install gatsby-richtext-reading-time-contentful
Add the plugin to your gatsby-config.js
file and if you want to specify the content types that you want to process, add the contentTypes
option.
module.exports = {
plugins: [
{
resolve: `gatsby-richtext-reading-time-contentful`,
options: {
contentTypes: [`ContentfulBlogPost`],
},
},
],
}
Once the plugin is installed and configured, it will process your specified Rich Text fields and add a new field called ${fieldName}TimeToRead to your GraphQL schema.
{
contentfulBlogPost(slug: { eq: $slug }) {
slug
title
fields {
DescriptionTimeToRead
}
}
}