「Hexo」Hexo 开启阅读计数功能

简述:本文简练描述 Hexo 博客如何开启自带的阅读计数功能。


1 leancloud配置

1.1 第一步

先注册。

1.2 第二步

创建应用,名字随意,计价方案为开发版
create an app

1.3 第三步

创建Class,名字必须Counter,默认ACL权限设置为无限制
create a class

1.4 第四步

设置中获取appidappkey,之后跳到**NexT配置**。
appid and appkey


2 NexT配置

打开NexT主题目录下的_config.yml,找到leancloud_visitors位置,并如下修改之。

1
2
3
4
5
6
7
8
9
10
11
# Show number of visitors to each article.
# You can visit https://leancloud.cn get AppID and AppKey.
leancloud_visitors:
enable: true
app_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx #<app_id>
app_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxx #<app_key>
# Dependencies: https://github.com/theme-next/hexo-leancloud-counter-security
# If you don't care about security in lc counter and just want to use it directly
# (without hexo-leancloud-counter-security plugin), set the `security` to `false`.
security: false # 如果设置了web安全域名,此处须改为 true。
betterPerformance: true

3 设置web安全域名(非必须)

设置->安全中心中,web安全域名处填写博客域名。
web secure domain

如果打开浏览器调试模式(F12),出现403错误,则意味着域名填写出错。
brower 403

那就只有两个办法:

  • 死磕
  • 放弃设置web安全域名

我选择第二个办法,毕竟第一个办法失败了,毕竟只是个小破站。所以,在NexT主题的_config.yml中将leancloud_visitorssecurity设置为false


以上!

作者

Alex

发布于

2018-09-09

更新于

2021-06-19

许可协议

评论