V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Bensendbs
V2EX  ›  问与答

求教 Hexo 使用多说的方法

  •  
  •   Bensendbs · 2015-03-20 11:29:45 +08:00 · 4113 次点击
    这是一个创建于 3319 天前的主题,其中的信息可能已经有所发展或是发生改变。

    这几天突然想给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>
    <% } %>

    12 条回复    2015-03-20 16:38:00 +08:00
    JingXiao
        1
    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
        2
    wuhuaji  
       2015-03-20 12:02:54 +08:00   ❤️ 1
    我用的是pacman这个主题,貌似默认就有多说了,没有折腾过。
    不过楼主你可以考虑一下这个主题 :)
    Bensendbs
        3
    Bensendbs  
    OP
       2015-03-20 12:08:49 +08:00
    @JingXiao 谢谢啊 我试试

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

    ```
    duoshuo_shortname: your-duoshuo-shortname
    ```
    JingXiao
        5
    JingXiao  
       2015-03-20 12:54:08 +08:00
    哎 原来 V2ex 回复不支持markdown的么?
    Bensendbs
        6
    Bensendbs  
    OP
       2015-03-20 13:43:07 +08:00
    @IIssNan 我是这样添加的
    duoshuo_shortname: santong.duoshuo.com
    额 不会是要duoshuo_shortname: santong-duoshuo-com。。。吧
    Bensendbs
        7
    Bensendbs  
    OP
       2015-03-20 13:43:41 +08:00
    @JingXiao 好像是的。。
    Bensendbs
        8
    Bensendbs  
    OP
       2015-03-20 13:56:25 +08:00
    @IIssNan 解决了。。只要shortname 就好了,废了那么大功夫原来是自己没有理解真正的意思。。谢谢了
    Bensendbs
        9
    Bensendbs  
    OP
       2015-03-20 14:31:30 +08:00
    @IIssNan 麻烦再请教下怎么设置首页不出现评论框。。
    IIssNan
        10
    IIssNan  
       2015-03-20 16:25:20 +08:00   ❤️ 1
    @Bensendbs 检查下 Hello world 那篇文章的内容,是否多加了什么
    Bensendbs
        11
    Bensendbs  
    OP
       2015-03-20 16:35:58 +08:00
    @IIssNan 哦哦 好的
    Bensendbs
        12
    Bensendbs  
    OP
       2015-03-20 16:38:00 +08:00
    @IIssNan 十分感谢!!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2937 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 03:35 · PVG 11:35 · LAX 20:35 · JFK 23:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.