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

如何让 Disqus 的评论数只显示数字?

  •  
  •   DoraJDJ · 2016-06-17 22:05:14 +08:00 · 1205 次点击
    这是一个创建于 2901 天前的主题,其中的信息可能已经有所发展或是发生改变。
    抱歉冒犯各位,新人又来提问了。

    我想问一下怎么让 Disqus 的评论数只显示数字而不显示其他字符,举个例子:

    `1 Comment`,把它变成`1`(只有数字,没有“ Comment ”的后缀)

    我在一位 V 友的 Blog 里发现了这个: http://moxfive.xyz/2016/06/14/duoshuo-disqus-comment-count/ ,但是不知道为什么在我这里不生效。

    因为我要把它用于我的 Hexo 主题,所以请不要回答“在 Disqus 后台设置就好了”之类的答案,谢谢。 :)
    1 条回复    2016-06-18 12:12:18 +08:00
    DoraJDJ
        1
    DoraJDJ  
    OP
       2016-06-18 12:12:18 +08:00
    自己捣鼓了下,暂时解决:
    ```
    <script>
    var dcc = $('.disqus-comment-count');
    dcc.one('DOMNodeInserted', function(a) {
    var b = $(this).text().replace(/[^0-9]/ig, '');
    if (b !== '' && b < 1) {$(this).remove(); return;}
    $(this).text(b);
    $(this).addClass('ui blue circular label');
    });
    </script>
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5572 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 02:37 · PVG 10:37 · LAX 19:37 · JFK 22:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.