【解决】使用LeanCloud配置Next主题文章浏览量显示不正常的问题

刚开始搭建博客,决定给所有文章添加浏览量,并在首页显示
参考了很多教程,但还是遇到了坑,特此记录一下
主要解决了利用LeanCloud解决博客访问量显示不正常的问题

以下内容均转载自我的博客(欢迎访问,手动狗头
使用LeanCloud配置Next主题文章浏览量的坑

关于LeanCloud的配置

可以参考大佬的博客

为NexT主题添加文章阅读量统计功能

值得注意的是,Next最新版已经集成了LeanCloud的相关配置,故不需要对其他文件进行修改,仅需要修改主题配置文件_config.yml

关于_config.yml的配置

在这里遇到了一个坑

参考教程对_config.yml进行修改如下:

leancloud_visitors:
    enable: true
    app_id: xxx
    app_key: xxx
    # Required for apps from CN region
    server_url: 
    # 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: true

发现修改后首页显示阅读量如下(看上去挺正常,少得可怜):

Next主题LeanCloud配置错误首页

但是!

打开文章后发现,阅读次数直接不显示了

Next主题LeanCloud配置错误首页文章内容

经过一系列花里胡哨的操作(熬夜脱发)后

  • 改js
  • 重置LeanCloud应用
  • 改LeanCloud节点,换国际版

终于找到了答案

_config.yml配置文件中找到valine的配置,填入LeanCloud的appid与appkey,并更改为:

valine:
  enable: true
  appid: xxx
  appkey: xxx
  notify: false # Mail notifier
  verify: false # Verification code
  placeholder: Just go go # Comment box placeholder
  avatar: mm # Gravatar style
  guest_info: nick,mail,link # Custom comment header
  pageSize: 10 # Pagination size
  language: # Language, available values: en, zh-cn
  visitor: false # Article reading statistic
  comment_count: true # If false, comment count will only be displayed in post page, not in home page
  recordIP: false # Whether to record the commenter IP
  serverURLs: # When the custom domain name is enabled, fill it in here (it will be detected automatically by default, no need to fill in)
  #post_meta_order: 0

最关键的地方在于设置 visitor: false

因为valine中的visitor与前面提到的leancloud_visitors配置冲突,故仅需要在这里设置为false即可


至此就完成了Next主题下文章浏览量的配置

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值