Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

考虑添加进各个hexo主题 #4

Open
Ovi3 opened this issue Apr 1, 2024 · 0 comments
Open

考虑添加进各个hexo主题 #4

Ovi3 opened this issue Apr 1, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Ovi3
Copy link

Ovi3 commented Apr 1, 2024

我的博客是hexo 和 fluid 主题搭建的, fluid主题支持不蒜子,开启下就行,不用编辑代码。

因为不蒜子有移动端的问题,我转成了vercount,不过有些麻烦:

  1. 修改 _config.fluid.yml (加上?i=以忽略fluid在后面添加的部分):
  # busuanzi: https://busuanzi.ibruce.info/busuanzi/2.3/
  busuanzi: https://cn.vercount.one/js?i=
  1. 修改 themes/fluid/layout/_partial/scripts.ejs , 加了段script:
<% if ((theme.footer.statistics.enable && theme.footer.statistics.source === 'busuanzi')
  || (page.meta !== false && theme.post.meta.views.enable && theme.post.meta.views.source === 'busuanzi')) { %>

<script>

function observeAndDisplay(sourceId, targetId) {
  if (document.getElementById(sourceId)) {
    new MutationObserver(m => {
      m.forEach(m => {
        if (m.target.textContent.trim() !== '') {
          document.getElementById(targetId).style.display = 'inline';
        }
      });
    })
      .observe(
        document.getElementById(sourceId),
        { childList: true, characterData: true, subtree: true }
      ); 
  }
    
} 

observeAndDisplay('busuanzi_value_page_pv', 'busuanzi_container_page_pv');
observeAndDisplay('busuanzi_value_site_pv', 'busuanzi_container_site_pv');
observeAndDisplay('busuanzi_value_site_uv', 'busuanzi_container_site_uv');
    

</script> 

  <%- js_ex(theme.static_prefix.busuanzi, 'busuanzi.pure.mini.js', 'defer') %>
<% } %>

可以考虑添加进各个hexo主题,改成用vercount统计不用这么麻烦

@EvanNotFound EvanNotFound added the enhancement New feature or request label Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants