DoraJDJ
V2EX  ›  问与答

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

  •  
  •   DoraJDJ · Jun 17, 2016 · 1549 views
    This topic created in 3642 days ago, the information mentioned may be changed or developed.
    抱歉冒犯各位,新人又来提问了。

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

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

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

    因为我要把它用于我的 Hexo 主题,所以请不要回答“在 Disqus 后台设置就好了”之类的答案,谢谢。 :)
    1 replies    2016-06-18 12:12:18 +08:00
    DoraJDJ
        1
    DoraJDJ  
    OP
       Jun 18, 2016
    自己捣鼓了下,暂时解决:
    ```
    <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>
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3742 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 04:30 · PVG 12:30 · LAX 21:30 · JFK 00:30
    ♥ Do have faith in what you're doing.