求教 Hexo 使用多说的方法

2015-03-20 11:29:45 +08:00
 Bensendbs

这几天突然想给blog加一个评论功能 但是无论按照多说官方的教程还是google出来的方式
都没有办法实现,想请教下各位是怎么配置的

我用的主题是:NexT 没有comment.ejs
下面是我对article.ejs的修改
<% if (page.comments){ %>
<section id="comments">
<!-- 多说评论框 start -->
<div class="ds-thread" data-thread-key="<%= page.path %>" data-title="<%= page.title %>" data-url="<%= page.permalink %>"></div>
<!-- 多说评论框 end -->
<!-- 多说公共JS代码 start (一个网页只需插入一次) -->
<script type="text/javascript">
var duoshuoQuery = {short_name:'<%= config.duoshuo_shortname %>'};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- 多说公共JS代码 end -->
</section>
<% } %>

4120 次点击
所在节点    问与答
12 条回复
JingXiao
2015-03-20 11:47:58 +08:00
````
<% if (!index && post.comments){ %>
<section id="comments">
<!-- Duoshuo Comment BEGIN -->
<div class="ds-thread" data-thread-key="<%= post.layout %>-<%= post.slug %>" data-title="<%= post.title %>" data-url="<%- post.permalink %>"></div>
<script type="text/javascript">
var duoshuoQuery = {short_name:"wangjingxiao"};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = 'http://static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- Duoshuo Comment END -->
</section>
<% } %>
````
我用的是landscape 好像也没找到comment.ejs,上述是我的article.ejs的多说配置,供参考
wuhuaji
2015-03-20 12:02:54 +08:00
我用的是pacman这个主题,貌似默认就有多说了,没有折腾过。
不过楼主你可以考虑一下这个主题 :)
Bensendbs
2015-03-20 12:08:49 +08:00
@JingXiao 谢谢啊 我试试

@wuhuaji 额 个人比较喜欢简约些的 不过还是谢谢啦
IIssNan
2015-03-20 12:45:40 +08:00
只要在站点的 `_config.yml` (主题的 `_config.yml` 也可以)中添加多说的配置就可以:

```
duoshuo_shortname: your-duoshuo-shortname
```
JingXiao
2015-03-20 12:54:08 +08:00
哎 原来 V2ex 回复不支持markdown的么?
Bensendbs
2015-03-20 13:43:07 +08:00
@IIssNan 我是这样添加的
duoshuo_shortname: santong.duoshuo.com
额 不会是要duoshuo_shortname: santong-duoshuo-com。。。吧
Bensendbs
2015-03-20 13:43:41 +08:00
@JingXiao 好像是的。。
Bensendbs
2015-03-20 13:56:25 +08:00
@IIssNan 解决了。。只要shortname 就好了,废了那么大功夫原来是自己没有理解真正的意思。。谢谢了
Bensendbs
2015-03-20 14:31:30 +08:00
@IIssNan 麻烦再请教下怎么设置首页不出现评论框。。
IIssNan
2015-03-20 16:25:20 +08:00
@Bensendbs 检查下 Hello world 那篇文章的内容,是否多加了什么
Bensendbs
2015-03-20 16:35:58 +08:00
@IIssNan 哦哦 好的
Bensendbs
2015-03-20 16:38:00 +08:00
@IIssNan 十分感谢!!

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/178189

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX