美文网首页Hexo
Hexo博客Next主题阅读次数热度不能读取的问题,报错Coun

Hexo博客Next主题阅读次数热度不能读取的问题,报错Coun

作者: 南峰QAQ | 来源:发表于2019-02-22 13:23 被阅读0次

    加入valine在线评论

    设置效果:

    设置方法:
    首先要先去LeanCloud注册一个帐号.然后再创建一个应用.

    拿到appidappkey之后,打开themes/next/_config.yml主题配置文件,查找valine,填入appidappkey
    我的配置:

    # You can get your appid and appkey from https://leancloud.cn
    # More info available at https://valine.js.org
    valine:
      enable: true # When enable is set to be true, leancloud_visitors is recommended to be closed for the re-initialization problem within different leancloud adk version.
      appid: 
      appkey: 
      notify: true # mail notifier, See: https://github.com/xCss/Valine/wiki
      verify: true # Verification code
      placeholder: 欢迎交流讨论... # comment box placeholder
      avatar: mm # gravatar style
      guest_info: nick,mail,link # custom comment header
      pageSize: 10 # pagination size
      visitor: false # leancloud-counter-security is not supported for now. When visitor is set to be true, appid and appkey are recommended to be the same as leancloud_visitors' for counter compatibility. Article reading statistic https://valine.js.org/visitor.html
      comment_count: true # if false, comment count will only be displayed in post page, not in home page
    
    

    Hexo添加阅读次数

    next 集成了 leancloud 。可以在leancloud进行账号注册。
    创建一个新的应用。点击应用进入。
    创建名称为CounterClass,名称必须为Counter

    k1gdSK.md.png

    点击设置 > 应用Key 复制App ID 和 App Key

    k1gUW6.md.png

    修改配置文件
    在主题themes目录下有第三方提供的主题配置文件\themes\next_config.yml
    打开主题配置文件 添加app_idapp_key:

    # Show number of visitors to each article.
    # You can visit https://leancloud.cn get AppID and AppKey.文章热度
    leancloud_visitors:
      enable: true
      app_id: llBsNPTabKsl2d4aU3OvrmSz-gzGzoHsz
      app_key: gzSQowSIzhnuc5eYPj4k7c7z
      # Dependencies: https://github.com/theme-next/hexo-leancloud-counter-security
      # If you don't care about security in leancloud counter and just want to use it directly
      # (without hexo-leancloud-counter-security plugin), set `security` to `false`.
      security: false
      betterPerformance: false
    

    修改统计设置
    打开主题配置文件 定位到 post_wordcount

    # Post wordcount display settings
    # Dependencies: https://github.com/willin/hexo-wordcount
    post_wordcount:
      item_text: true
      wordcount: true
      min2read: true
      totalcount: false
      separated_meta: true
    

    Web安全性
    为了保证应用的统计计数功能仅应用于自己的博客,你可以在应用 > 设置 > 安全中心的Web安全域名中加入自己的博客域名,保证数据的调用安全。

    k1gwQO.md.png

    显示文章热度

    首先要先去LeanCloud注册一个帐号.然后再创建一个应用.

    设置方法:
    next主题集成leanCloud,打开themes/next/layout/_macro/post.swig,准备添加

              {# LeanCloud PageView #}
              {% if theme.leancloud_visitors.enable or (theme.valine.enable and theme.valine.appid and theme.valine.appkey and theme.valine.visitor) %}
                <span id="{{ url_for(post.path) }}" class="leancloud_visitors" data-flag-title="{{ post.title }}">
                  <span class="post-meta-divider">|</span>
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  {% if theme.post_meta.item_text %}
                    <span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
                  {% endif %}
                    <span class="leancloud-visitors-count"></span>
                  <span>℃</span>
                </span>
              {% endif %}
    

    插入摄氏度到倒数第三句,如下:

    <span>℃</span>
    

    打开,themes/next/languages/zh-CN.yml,将views后的文字描述改为热度.

    views: 热度
    

    有的版本不一样,打开,themes/next/languages/zh-Hans.yml,将以下

    visitors: 热度
    

    然后打开themes/next/_config.yml找到leancloud_visitors,将enable:改成true,再填上自己LeanCloudapp_idapp_key

    # Show number of visitors to each article.
    # You can visit https://leancloud.cn get AppID and AppKey.文章热度
    leancloud_visitors:
      enable: true
      app_id: 你自己的id
      app_key: 你自己的key
      # Dependencies: https://github.com/theme-next/hexo-leancloud-counter-security
      # If you don't care about security in leancloud counter and just want to use it directly
      # (without hexo-leancloud-counter-security plugin), set `security` to `false`.
      security: true
      betterPerformance: false
    

    报错Counter not initialized! More info at console err msg.

    相关文章

      网友评论

        本文标题:Hexo博客Next主题阅读次数热度不能读取的问题,报错Coun

        本文链接:https://www.haomeiwen.com/subject/vaxeyqtx.html