Disqus 实际上有一个非常好的 React 组件——https://js.coach/?search =disqus
您只需将其添加到降价包装器( wrappers/md.js
)并传入帖子网址。
我找到了我认为需要添加的代码,但不确定应该将其嵌入到 wrappers/md.js 文件的哪个位置。
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}/>
);
}
});
反应。渲染(
因为这是“gatsby disqus comments”搜索的最高结果。 现在这里有一个官方的 react-disqus 组件https://github.com/disqus/disqus-react和一篇关于如何配置的博客文章https://mk.gg/add-disqus-comments-to-gatsby-博客/。 我刚刚使用 gatsby-starter-blog 入门工具包在我的博客上完成了这项工作!
最有用的评论
Disqus 实际上有一个非常好的 React 组件——https://js.coach/?search =disqus
您只需将其添加到降价包装器(
wrappers/md.js
)并传入帖子网址。