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

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

# 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: -user">> 本站访客数
  site_uv_footer: 人次
  # custom pv span for the whole site
  site_pv: true
  site_pv_header: -eye">> 本站总访问量
  site_pv_footer:# custom pv span for one page only
  page_pv: true
  page_pv_header: -eye">> 浏览
  page_pv_footer:

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

# 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文件中增加自己想要的文本标记即可,如:

{% 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') }}">
     本站访客数 <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') }}">
     本站总访问量 <span class="busuanzi-value" id="busuanzi_value_site_pv">span>span>	
  span>
{% endif %}
div>
{% endif %}

效果
Next v7.1.2主题增加博客页脚访客统计_第1张图片
欢迎访问我的博客:ZhaoJuntao’s Blog

你可能感兴趣的:(Hexo)