GHOST搭建疑难问题记录(二)

ghost博客添加评论和网站统计

GHOST搭建疑难问题记录(二)

在/ghost/core/content/thems/casper下,修改default.hbs,引入js文件

<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<script src="//unpkg.com/valine/dist/Valine.min.js"></script>

1.网站评论系统

使用valine+leancloud,需要先在leanclound上注册信息,支持免费版,但是有使用限制,获取appid,appkey,在post.hbs原来的comments处注释原来的评论模块,然后添加valine相关的内容

        {{!-- <section class="article-comments gh-canvas">
            {{comments}}
        </section> --}}
        {{!--评论模块--}}

    <div>{{ @custom.post_image_style}}</div>
    <div id="vcomments" class="gh-content gh-canvas"></div>
    <script>
        new Valine({
            el: '#vcomments', // #vcomments:评论模块 div 的class
            appId: '你在leancloud申请的id',
            appKey: '你在leancloud申请的key',
            avatar: 'wavatar', // (''/mp/identicon/monsterid/wavatar/robohash/retro/hide) 评论者头像生产方式
            placeholder: '有话请说~', // 评论输入框中显示的内容
            requiredFields:['mail'],
            meta:['nick','mail']
        })
    </script>
    <script
        src="https://code.jquery.com/jquery-3.5.1.min.js"
        integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
        crossorigin="anonymous">
    </script>

2.网站访问统计

 使用busuanzi,default.hbs的footer处进行如下

    <footer class="site-footer outer">
        <div class="inner">
            <section class="copyright"><a href="{{@site.url}}">{{@site.title}}</a> &copy; {{date format="YYYY"}} Johnny.Kuang</section>
            <nav class="site-footer-nav">
                {{navigation type="secondary"}}
            </nav>
            <div>蜀ICP备11111号-1</div>
            <span id="busuanzi_container_site_pv">本站总访问量<span id="busuanzi_value_site_pv"></span>次</span>
            <span>本站访客数<span id="busuanzi_value_site_uv"></span>人次</span>
        </div>
    </footer>