Landscape-plus主题使用的是”多说“,但是多说早就停止运营了。
所以考虑其他的评论系统替换,这儿我查找了其他的评论如Disqus、Gitment、来必力等,如果需要集成Gitment评论系统的可以参考这一篇文章,我最后选择了valine。
这儿参考了博客添加评论系统这篇文章,感谢这位小哥!
使用valine介绍
高速,使用国内后端云服务提供商 LeanCloud 提供的存储服务
开源,自定义程度高
支持邮件通知
支持验证码
支持 Markdown
valine 的安装和使用
前往https://leancloud.cn注册 appid和appkey。
这儿是对landscape-plus修改,替换之前的
Duoshuo,首先打开主题下的_config.yml去掉主题下的
1 | # Duoshuo |
“换成”
1 | #valine leancloud |
- 再打开
\themes\landscape-plus\layout_partial\after-footer.ejsafter-footer.ejs文件从第4行到32行换成valine的。
1 | <% if (config.duoshuo_shortname || theme.duoshuo_shortname){ %> |
这儿值得注意的是
1 | 这种格式的在next主题下是可以读取的 |
- 然后再打开
/themes/landscape-plus/layout/_partial/article.ejsarticle.ejs文件从32行到36换成valine的代码。
1 | <% if (post.comments && (config.duoshuo_shortname || theme.duoshuo_shortname)){ %> |
还是该文件把46行到56行替换掉
1 | <% if (!index && post.comments && (config.duoshuo_shortname || theme.duoshuo_shortname)){ %> |
- 最后一步
Valine.min.js放到/themes\landscape-plus\source\js文件夹内,这儿是Valine.min.js下载链接,只保存Valine.min.js文件就行了。因为前面 <script src=”/js/Valine.min.js”></script> 已经引用的这个文件。
这儿为止,valine就替换完成了
hexo clean重新清除一下,然后再hexo g重新生成就可以看到评论系统了。
如果出现评论按钮没有说明你这儿写的格式有问题:
1 | new Valine({ |
仔细再检查一下,不行的话只添加av、el、app_id、app_key试试看看能不能正常运行,一个一个字段的添加。
