Bensendbs
V2EX  ›  问与答

求教 Hexo 使用多说的方法

  •  
  •   Bensendbs · Mar 20, 2015 · 4929 views
    This topic created in 4087 days ago, the information mentioned may be changed or developed.

    这几天突然想给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 replies    2015-03-20 16:38:00 +08:00
    JingXiao
        1
    JingXiao  
       Mar 20, 2015
    ````
    <% 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  
       Mar 20, 2015   ❤️ 1
    我用的是pacman这个主题,貌似默认就有多说了,没有折腾过。
    不过楼主你可以考虑一下这个主题 :)
    Bensendbs
        3
    Bensendbs  
    OP
       Mar 20, 2015
    @JingXiao 谢谢啊 我试试

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

    ```
    duoshuo_shortname: your-duoshuo-shortname
    ```
    JingXiao
        5
    JingXiao  
       Mar 20, 2015
    哎 原来 V2ex 回复不支持markdown的么?
    Bensendbs
        6
    Bensendbs  
    OP
       Mar 20, 2015
    @IIssNan 我是这样添加的
    duoshuo_shortname: santong.duoshuo.com
    额 不会是要duoshuo_shortname: santong-duoshuo-com。。。吧
    Bensendbs
        7
    Bensendbs  
    OP
       Mar 20, 2015
    @JingXiao 好像是的。。
    Bensendbs
        8
    Bensendbs  
    OP
       Mar 20, 2015
    @IIssNan 解决了。。只要shortname 就好了,废了那么大功夫原来是自己没有理解真正的意思。。谢谢了
    Bensendbs
        9
    Bensendbs  
    OP
       Mar 20, 2015
    @IIssNan 麻烦再请教下怎么设置首页不出现评论框。。
    IIssNan
        10
    IIssNan  
       Mar 20, 2015   ❤️ 1
    @Bensendbs 检查下 Hello world 那篇文章的内容,是否多加了什么
    Bensendbs
        11
    Bensendbs  
    OP
       Mar 20, 2015
    @IIssNan 哦哦 好的
    Bensendbs
        12
    Bensendbs  
    OP
       Mar 20, 2015
    @IIssNan 十分感谢!!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4796 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 05:37 · PVG 13:37 · LAX 22:37 · JFK 01:37
    ♥ Do have faith in what you're doing.