Next v7.1.2主题增加博客页脚访客统计

  博客之前使用的Next版本为v5.1.4,如果想在博客页脚增加访客统计功能需要修改主题配置文件_config.yml中的site_uv_headersite_pv_header属性值来增加访客标记,如下面所示。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Show PV/UV of the website/page with busuanzi.
# Get more information on http://ibruce.info/2015/04/04/busuanzi/
busuanzi_count:
# count values only if the other configs are false
enable: true
# custom uv span for the whole site
site_uv: true
site_uv_header: <i class="fa fa-user"></i> 本站访客数
site_uv_footer: 人次
# custom pv span for the whole site
site_pv: true
site_pv_header: <i class="fa fa-eye"></i> 本站总访问量
site_pv_footer:
# custom pv span for one page only
page_pv: true
page_pv_header: <i class="fa fa-eye"></i> 浏览
page_pv_footer:

  Next升级到v7.1.2版本后,去掉了header属性,因此默认只有访客数量的显示,如果需要在博客页脚增加访客文本标记或者其它自己想要使用的文本,需要进行以下配置。
  首先将主题配置文件中busuanzi_count功能打开,如下所示。

1
2
3
4
5
6
7
8
9
10
# Show Views / Visitors of the website / page with busuanzi.
# Get more information on http://ibruce.info/2015/04/04/busuanzi
busuanzi_count:
enable: true
total_visitors: true
total_visitors_icon: user
total_views: true
total_views_icon: eye
post_views: true
post_views_icon: eye

  然后在/theme/next/layout/_third-party/analytics/busuanzi-counter.swig文件中增加自己想要的文本标记即可,如:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  {% if theme.busuanzi_count.enable %}
<div class="busuanzi-count">
<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

{% if theme.busuanzi_count.total_visitors %}
<span class="post-meta-item-icon">
<i class="fa fa-{{ theme.busuanzi_count.total_visitors_icon }}"></i>
</span>
<span class="site-uv" title="{{ __('footer.total_visitors') }}">
&nbsp;本站访客数&nbsp;<span class="busuanzi-value" id="busuanzi_value_site_uv"></span></span>
</span>
{% endif %}

{% if theme.busuanzi_count.total_visitors and theme.busuanzi_count.total_views %}
<span class="post-meta-divider">|</span>
{% endif %}

{% if theme.busuanzi_count.total_views %}
<span class="post-meta-item-icon">
<i class="fa fa-{{ theme.busuanzi_count.total_views_icon }}"></i>
</span>
<span class="site-pv" title="{{ __('footer.total_views') }}">
&nbsp;本站总访问量&nbsp;<span class="busuanzi-value" id="busuanzi_value_site_pv"></span></span>
</span>
{% endif %}
</div>
{% endif %}

效果
visitor

-------------本文结束感谢阅读-------------
坚持原创技术分享,您的支持将鼓励我继续创作!