gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.27k stars 10.31k forks source link

Is there a way to add Disqus comments to the Gatsby Blog #131

Closed Oppenheimer1 closed 8 years ago

Oppenheimer1 commented 8 years ago

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.

KyleAMathews commented 8 years ago

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.

Oppenheimer1 commented 8 years ago

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'));

ElijahLynn commented 5 years ago

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!