gatsby-remark-reading-time-v2
v1.0.2
Published
Adds an estimated reading time field to all remark nodes
Downloads
3
Maintainers
Readme
gatsby-remark-reading-time
Adds a medium-like reading time estimate to your gatsby remark posts. Powered by reading-time
.
Installation
- Install
yarn add gatsby-remark-reading-time
- Add to
gatsby-transformer-remark
plugins ingatsby-config.js
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
`gatsby-remark-reading-time`,
// ...
],
},
},
Usage
The reading time can be queried in the fields of markdownRemark nodes. An example of this in a single post would look like this:
export const query = graphql`
query($slug: String!) {
markdownRemark(fields: { slug: { eq: $slug } }) {
htmlAst
excerpt(pruneLength: 200)
frontmatter {
title
date(formatString: "MMMM Do, YYYY")
}
fields {
slug
readingTime {
text
}
}
}
}
`;
There are 4 available values in readingTime
:
text
: '1 min read',minutes
: 1,time
: 60000,words
: 200
License
MIT