Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adds reading time estimation to index and post
  • Loading branch information
doppelganger9 committed Mar 8, 2019
1 parent d608bc3 commit bfbdee1
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 23 deletions.
1 change: 1 addition & 0 deletions gatsby-config.js
Expand Up @@ -44,6 +44,7 @@ module.exports = {
`gatsby-remark-copy-linked-files`,
`gatsby-remark-smartypants`,
`@weknow/gatsby-remark-twitter`,
`gatsby-remark-reading-time`,
],
},
},
Expand Down
95 changes: 73 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -21,6 +21,7 @@
"gatsby-remark-copy-linked-files": "^2.0.9",
"gatsby-remark-images": "^2.0.6",
"gatsby-remark-prismjs": "^3.2.4",
"gatsby-remark-reading-time": "1.0.1",
"gatsby-remark-responsive-iframe": "^2.0.9",
"gatsby-remark-smartypants": "^2.0.8",
"gatsby-source-filesystem": "^2.0.22",
Expand Down
2 changes: 1 addition & 1 deletion src/components/posts-list.js
Expand Up @@ -16,7 +16,7 @@ export default function ListOfPosts({ posts }) {
{title}
</Link>
</h3>
<small>{node.frontmatter.date}</small>
<small>{node.frontmatter.date} - {node.fields.readingTime.text}</small>
<p
dangerouslySetInnerHTML={{
__html: node.frontmatter.description || node.excerpt,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/index.js
Expand Up @@ -43,6 +43,9 @@ export const pageQuery = graphql`
excerpt
fields {
slug
readingTime {
text
}
}
frontmatter {
date(formatString: "MMMM DD, YYYY")
Expand Down
6 changes: 6 additions & 0 deletions src/templates/blog-post.js
Expand Up @@ -29,6 +29,7 @@ class BlogPostTemplate extends React.Component {
>
{post.frontmatter.date}
</p>
<p style={{ ...scale(-2/5), display: `block`, marginTop: rhythm(-1), marginBottom: rhythm(2) }} >{post.fields.readingTime.text}</p>
<div dangerouslySetInnerHTML={{ __html: post.html }} />
<hr
style={{
Expand Down Expand Up @@ -85,6 +86,11 @@ export const pageQuery = graphql`
date(formatString: "MMMM DD, YYYY")
description
}
fields {
readingTime {
text
}
}
}
}
`

0 comments on commit bfbdee1

Please sign in to comment.