Gatsby: Is there a way to add Disqus comments to the Gatsby Blog

Created on 20 Feb 2016  ·  3Comments  ·  Source: gatsbyjs/gatsby

Is there a way to add Disqus comments to the Gatsby Blog? I was walking through the steps here: https://github.com/gatsbyjs/gatsby but wasn't sure where to incorporate the Disqus comment option. Any help would be much appreciated.

Most helpful comment

There's actually a really nice React component for Disqus — https://js.coach/?search=disqus

You'll just want to add that to the markdown wrapper (wrappers/md.js) and pass in the post url.

All 3 comments

There's actually a really nice React component for Disqus — https://js.coach/?search=disqus

You'll just want to add that to the markdown wrapper (wrappers/md.js) and pass in the post url.

I found the code I think I need to add but wasn't sure where I should embed it within the wrappers/md.js file.

var React = require('react');
var ReactDisqusThread = require('react-disqus-thread');

var App = createClass({

handleNewComment: function(comment) {
    console.log(comment.text);
}

render: function () {
    return (
        <ReactDisqusThread
            shortname="example"
            identifier="something-unique-12345"
            title="Example Thread"
            url="http://www.example.com/example-thread"
            category_id="123456"
            onNewComment={this.handleNewComment}/>
    );
}

});

React.render(, document.getElementById('container'));

Since this comes up as top result for "gatsby disqus comments" search. There is now an official react-disqus component here https://github.com/disqus/disqus-react and a blog post on how to configure here https://mk.gg/add-disqus-comments-to-gatsby-blog/. I just got this working on my blog using the gatsby-starter-blog starter kit!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandonmp picture brandonmp  ·  3Comments

signalwerk picture signalwerk  ·  3Comments

hobochild picture hobochild  ·  3Comments

jimfilippou picture jimfilippou  ·  3Comments

benstr picture benstr  ·  3Comments