Add comments
Since most of the boilerplate additions to our headless WordPress are complete, we may want to add comments using Disqus. Skip if you don’t need comments.
Install
gatsby-plugin-disqus
yarn add gatsby-plugin-disqus
Update
gatsby-config
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-disqus`,
options: {
shortname: `YOUR_DISQUS_SHORTNAME`
}
},
]
}
template/post
import { Disqus, CommentCount } from 'gatsby-plugin-disqus
class Post extends Component {
render() {
const disqusConfig = {
url: `${this.props.data.site.siteMetadata.siteUrl+post.slug}`,
identifier: post.id,
title: post.title,
}
return (
<Layout>
<CommentCount config={disqusConfig} placeholder={'...'} />
<Disqus config={disqusConfig} />
</Layout>
)
}
}
Deploy
yarn deploy
Sources
Previous: Add robots
...