hugo主题增加valine评论功能_test

步骤

1. 配置Leancloud

这部分详细参考:hugo博客添加评论系统Valine

2. 更改 comments.html 文件

将整体内容替换成如下代码:

<!-- valine change from origin code-->
  {{- if .Site.Params.valine.enable -}}
  <!-- id 将作为查询条件 -->
  
  <div id="vcomments"></div>
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src='//unpkg.com/valine/dist/Valine.min.js'></script>

  <script type="text/javascript">
    new Valine({
        el: '#vcomments' ,
        appId: '{{ .Site.Params.valine.appId }}',
        appKey: '{{ .Site.Params.valine.appKey }}',
        notify: '{{ .Site.Params.valine.notify }}', 
        verify: '{{ .Site.Params.valine.verify }}', 
        avatar:'{{ .Site.Params.valine.avatar }}', 
        placeholder: '{{ .Site.Params.valine.placeholder }}',
        visitor: '{{ .Site.Params.valine.visitor }}'
    });
  </script>
  {{- end -}}

3. 引入评论

layouts/_default/single.html 中引入评论,本主题已有配置:

  {{ if not ( eq .Params.comments false) }}
    {{ .Render "comments" }}
  {{ end }}

参考

comments powered by Disqus