本文主要是关于 评论系统hexo-yilia 主题中的添加和配置。使用主题: hexo-theme-yilia-plus

常用系统

目前hexo可用的评论系统比较多,如:畅言、来必力、Disqus、Gitment、gitalk、utterances、Giteement、valine等等。不过有些已关停服务。

这里列举五个hexo常用的评论系统:

  • 1、gitment :基于GitHub issue的评论系统,可参考:简书;
  • 2、gitalk : 基于GitHub issue的评论系统,可参考:gitalk;
  • 3、utterance : 基于GitHub issue的评论系统,可参考:详情
  • 4、giteement : 码云评论系统,国内用户建议使用这个,相对比较快,详情;
  • 5、valine : valine 评论系统,到 leancloud 进行注册。

1.Gitment配置

首先要注册 OAuth Application 当别人评论你的文章时,会需要它是授权。

注册成功后,会获取到 Client ID/scerct ,需要填入配置文件中。

打开文件 themes\yilia-plus\_config.yml , 修改配置:

gitment_owner: ''      # 你的 GitHub ID (github 账户名)
# 是否使用官方js(false可以提升访问速度,本地修改过一部分的js,官方js可能会出现服务器不稳定,不太建议使用)
gitment_repo: '如:xxx.github.io'  #存储评论的 repo name(需要在Github创建)
gitment_oauth:client_id: ''           #client IDclient_secret: ''       #client secret

themes\yilia-plus\layout\_partial\post 目录下,会默认有一个 gitment.ejs 文件,可以自定义样式
对应的 themes\yilia-plus\layout\_partial\article.ejs 文件,会有 gitment 相关的配置。

2.Gitalk配置

2.1.新建 gitalk.ejs 文件

gitment 类似配置,首先在 themes\yilia-plus\layout\_partial\post 目录下,新建 gitalk.ejs 文件,
添加如下内容:

<div id="gitalk-container" style="padding: 0px 30px 0px 30px;"></div> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script><script type="text/javascript">if(<%=theme.gitalk.enable%>){var gitalk = new Gitalk({clientID: '<%=theme.gitalk.ClientID%>',clientSecret: '<%=theme.gitalk.ClientSecret%>',repo: '<%=theme.gitalk.repo%>',owner: '<%=theme.gitalk.githubID%>',admin: ['<%=theme.gitalk.adminUser%>'],id: '<%= page.date %>',distractionFreeMode: '<%=theme.gitalk.distractionFreeMode%>'
})
gitalk.render('gitalk-container')
}
</script>

2.2.修改文件 comment.scss

在文件 themes\yilia\source-src\css\comment.scss 中,做如下修改:

#disqus_thread, .duoshuo, .cloud-tie-wrapper, #SOHUCS, #gitment-ctn, #gitalk-container {padding: 0 30px !important;min-height: 20px;
}#SOHUCS {#SOHU_MAIN .module-cmt-list .block-cont-gw {border-bottom: 1px dashed #c8c8c8 !important;}
}

2.3.修改主题配置文件 _config.yml

打开文件 themes\yilia-plus\_config.yml , 修改配置:

gitalk:enable:  truegithubID:  ''      # 写自己github的IDrepo:  ''          # 新建存放评论的仓库名ClientID:  ''      # 与 `gitment` 一样ClientSecret:  ''  # 同上adminUser:  ''     # 也填GitHub的IDdistractionFreeMode: true

2.4.在文件 article.ejs 中添加配置

打开 themes\yilia-plus\layout\_partial\article.ejs 文件,添加:

<% if(theme.gitalk.enable){ %><%- partial('post/gitalk', {key: post.slug,title: post.title,url: config.url+url_for(post.path)}) %><% } %>

3.Utterance配置

3.1.授权Utterance应用能访问仓库的issues

即安装 Utterance 应用,点击 install utterances,选择需要安装的仓库。

3.2.fork项目

GitHub 上 fork Utterance项目,按照它的教程在 SITES.md 文件中注册你的博客网址,否则可能会配置失败。

3.3.修改主题配置文件 _config.yml

打开文件 themes\yilia-plus\_config.yml , 修改配置:

# utteranc评论: https://utteranc.es (参数配置详见主页) 替换 gitment、gitalk
utterance:enable: truerepo: ''     #仓库名字,格式:你的用户ID/仓库名称,如:blog/utterance_repoissue_term: 'title'            #映射配置theme: 'github-light'          #主题

3.4.在文件 article.ejs 中添加配置

打开 themes\yilia-plus\layout\_partial\article.ejs 文件,添加:

<% if (theme.utterance && theme.utterance.enable){ %><section id="comments" class="comments"><style>.utterances{max-width: 100%;}</style><script src="https://utteranc.es/client.js"repo="<%= theme.utterance.repo %>"issue-term="<%= theme.utterance.issue_term %>"theme="<%= theme.utterance.theme %>"crossorigin="anonymous"async></script></section><% } %>

4.Giteement配置

基于码云的评论系统,类似GitHub的配置

4.1.新建 giteement.ejs 文件

themes\yilia-plus\layout\_partial\post 目录下,新建 giteement.ejs 文件,添加如下内容:

<% if (!index && post.comments && theme.giteement && theme.giteement.enable){ %><div id="giteement-ctn"></div><% if (theme.giteement && theme.giteement.remote){ %><link rel="stylesheet" href="https://giteement.oss-cn-beijing.aliyuncs.com/default.css"><script src="https://giteement.oss-cn-beijing.aliyuncs.com/giteement.browser.js"></script><% } else { %><link rel="stylesheet" href="<%- url_for('lib/default.css') %>"><script src="<%- url_for('lib/giteement.browser.js') %>"></script><% } %><script><!-- id: "<%= page.title %>" -->var giteement = new Giteement({id: '<%=page.date.format('YYYYMMDDHHmmss')%>',owner: '<%=theme.giteement.giteeID%>',repo: '<%=theme.giteement.repo%>',backcall_uri: '<%=theme.giteement.redirect_uri%>',oauth_uri: '<%=theme.giteement.oauth_uri%>',oauth: {client_id: '<%=theme.giteement.gitment_oauth.client_id%>',client_secret: '<%=theme.giteement.gitment_oauth.client_secret%>'},})giteement.render('giteement-ctn')</script>
<% } %>

4.2.修改主题配置文件 _config.yml

打开文件 themes\yilia-plus\_config.yml , 修改配置:

giteement:enable: true  # 是否启用码云评论系统# 是否使用官方js(false可以提升访问速度)remote: falseredirect_uri: ''   # 应用回调地址(请和配置的第三方应用保持一致)# 不能更改(网上开源项目https://github.com/Rob--W/cors-anywhere作者提供的专门用来跨域服务器的配置)oauth_uri: https://cors-anywhere.herokuapp.com/https://gitee.com/oauth/tokengiteeID: ''  # 你的码云账号英文名# 存储评论的 reporepo: yilia-plus-demogitment_oauth:client_id: '*********'           #client IDclient_secret: '*********'       #client secret

4.3.在文件 article.ejs 中添加配置

打开 themes\yilia-plus\layout\_partial\article.ejs 文件,添加:

<% if (theme.giteement && theme.giteement.enable){ %>
<%- partial('post/giteement', {key: post.slug,title: post.title,url: config.url+url_for(post.path)}) %>
<% } %>

5.Valine配置

5.1.注册 LeanCloud

先到 leancloud进行注册、创建应用等等,页面有帮助教程。

到【设置】-【应用keys】,找到 AppIDAppKey ,配置需要。

5.2.部署云引擎

  1. 在Leancloud 【云引擎】-【设置】界面,创建代码仓库,并保存:https://github.com/DesertsP/Valine-Admin.git
  2. 设置环境变量
  3. 部署(分支选master)

可参考:Valine配置手册

5.3.新建 valine.ejs 文件

themes\yilia-plus\layout\_partial\post 目录下,新建 valine.ejs 文件,添加如下内容:

<div class="valine_comment"></div>
<!--载入js,在</body>之前插入即可-->
<!--Leancloud 操作库:-->
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<!--Valine 的核心代码库-->
<script src="//unpkg.com/valine/dist/Valine.min.js"></script>
<script>var notify = '<%= theme.valine.notify %>' == true ? true : false;var verify = '<%= theme.valine.verify %>' == true ? true : false;new Valine({av: AV,el: '.valine_comment',emoticon_url: 'https://cloud.panjunwen.com/alu',emoticon_list: ["狂汗.png","不说话.png","汗.png","坐等.png","献花.png","不高兴.png","中刀.png","害羞.png","皱眉.png","小眼睛.png","暗地观察.png"],app_id: '<%= theme.valine.appid %>',app_key: '<%= theme.valine.appkey %>',placeholder: '<%= theme.valine.placeholder %>'});
</script>

5.4.修改主题配置文件 _config.yml

打开文件 themes\yilia-plus\_config.yml , 修改配置:

# valine 评论系统,到leancloud进行注册
# https://leancloud.cn/dashboard/login.html#/signup
valine:appid: ''  # Leancloud应用的appIdappkey: ''          # Leancloud应用的appKeyverify: false      # 验证码notify: true       # 评论回复提醒avatar: mm        # 评论列表头像样式(https://valine.js.org/avatar)placeholder: 欢迎您的评论~ # 评论框占位符

5.5.在文件 article.ejs 中添加配置

打开 themes\yilia-plus\layout\_partial\article.ejs 文件,添加:

<% if (theme.valine && theme.valine.appid && theme.valine.appkey){ %><section id="comments" style="margin:10px;padding:10px;background:#fff;"><%- partial('post/valine', {key: post.slug,title: post.title,url: config.url+url_for(post.path)}) %></section><% } %>

【Hexo搭建个人博客】:yilia主题配置(三) - 评论系统相关推荐

  1. 通过Hexo搭建个人博客以及主题配置

    这是蓝鸟x发布的第一篇文章 前言 直接在github page平台上托管我们的博客.这样就可以安心的来写作,又不需要定期维护,而且hexo作为一个快速简洁的博客框架,用它来搭建博客真的非常容易. He ...

  2. Hexo博客yilia主题添加Gitment评论系统

    gitment是imsun利用github上的issues做的评论系统,我这里大力推荐,原因有三: 注册简单,只要填写APP名和主页地址 实现方便,只要简单的配置 没有广告,这个很重要 注册OAuth ...

  3. Linux下使用 github+hexo 搭建个人博客04-next主题优化

    上篇我们说了 hexo 的优化,针对的站点的优化. 本篇讲解 next 主题的优化,包括:使用语言.前端页面显示宽度.菜单.侧栏.头像.添加或取消动画效果.打赏功能等等. 让页面排版更符合我们所要的功 ...

  4. 给hexo搭建的博客更换主题

    怎么给hexo搭建的博客更换主题 首先要进入hexo的官网主题界面,找到你所想要的主题 网址:https://hexo.io/themes/ 点进该主题,就会进入你选中的主题的拥有者的博客,你就可以看 ...

  5. Github部署+Hexo搭建免费博客 next主题美化

    前言 工作学习中难免会遇到一些问题,有些问题比较复杂,第一遇到了百度许久,第二次遇到了还是要百度许久!想想 倒不如遇到问题记下来写在博客上!以后好查阅.在CSDN上面看到hexo+github可以免费 ...

  6. Hexo博客NexT主题美化之评论系统

    前言 更多效果展示,请访问我的 个人博客. 效果图: Valine 诞生于2017年8月7日,是一款基于Leancloud的快速.简洁且高效的无后端评论系统. 教程: 登录 Leancloud 官网, ...

  7. 利用Hexo搭建个人博客-博客初始化篇

    上一篇博文 <利用Hexo搭建个人博客-环境搭建篇> 中,我们讲解了利用Hexo搭建个人博客应该要配置哪些环境. 相信大家已经迫不及待的想要知道接下来应该要怎么把自己的博客搭起来了,下面, ...

  8. Linux下使用 github+hexo 搭建个人博客01-hexo搭建

    为什么要搭建自己的博客系统? 原因有好几个吧,归类如下: 1.自己搭建博客系统很有成就感,可以自己选定页面风格和页面排版: 2.自己搭建博客系统可以根据自己的需要添加各种插件功能,因此整体上比网上的第 ...

  9. hexo博客yilia主题_缺失模块_解决方案

    hexo博客yilia主题,左侧栏目有一个全部文章的按钮,刚开始开始报错缺失模块,如下图: 我解决了这个问题着实不容易饶了弯路,但是跟着提示步骤,其实很简单,走起: 1.查看node版本 win键+R ...

  10. Github pages + Hexo 博客 yilia 主题使用畅言评论系统

    文章首发地址:http://www.54tianzhisheng.cn/2017/04/13/Hexo-yilia-changyan/ , 转载请注明出处. 前言 Hexo的Yilia主题由于原来使用 ...

最新文章

  1. 一文搞懂RNN(循环神经网络)
  2. 爬虫自动登陆GitHub
  3. 用命令行非交互改密码
  4. 收起.NET程序的dll来
  5. python语音分割_用7行Python代码构建自己的有声读物
  6. 1.3、解析并创建ApplicationListener(ok)
  7. html5做在线音乐,html5实现在线响应式音乐播放器
  8. 考试一个程序员,1f=0.1
  9. 软件工程 网络工程,职业方向是怎样的?选择之前一定要了解!
  10. android soundpool 封装,Android SoundPool的简单使用
  11. 【论文解读--Xdog】(宇树科技鼻祖)新型电驱式四足机器人研制与测试
  12. 独木舟上的旅行(贪心算法)
  13. 【verbs】IBV_WR API(3) Libibverbs Programmer’s Manual
  14. 如何打开.pdm文件(Mac OS X)
  15. python生成二维码教程_使用Python生成个性二维码
  16. linux中|管道符的作用
  17. ASEMI整流桥GBU808参数,GBU808介绍,GBU808详解
  18. 【Multisim仿真】二阶有源高通滤波电路仿真
  19. 高并发高流量的大型网站架构设计
  20. 计算机病毒手动查杀,手动查杀电脑病毒的一些基本方法

热门文章

  1. python运算符重载、并且编写复数类的加减乘除_编程基础篇:定义一个复数类Complex,重载运算符“+,-,*,/”,使之能用于复数的加减乘除.....出现的问题及代码...
  2. 深圳海伊视讯布控球成功对接海康萤石云平台安装调式
  3. ui设计需要做android和苹果版本,安卓和IOS系统对于UI设计来说一样吗
  4. Java堆:Shallow Size和Retained Size
  5. html5最新滚动效果,jQuery和CSS3炫酷滚动页面内容元素动画特效插件
  6. php数组倒插,phpComasy v0.7.9
  7. 计算机专门存储数据的单元,认识算法的数据存储单元——变量
  8. 3大类6种排序 插入排序 选择排序 冒泡排序 希尔排序 堆排序 快速排序 —————— 开开开山怪
  9. 什么是网易企业邮箱客户端专有协议?
  10. 从数据分析看王祖贤的电影人生