为hexo博客添加基于gitment评论功能

简介: **关于gitment**gitment其实就是利用你的代码仓库的Issues,来实现评论。每一篇文章对应该代码仓库中的一个Issues,Issues中的评论对应你的博客每篇文章中的评论。如果你是用github的博客的话用起来将会十分的方便。
**关于gitment** gitment其实就是利用你的代码仓库的Issues,来实现评论。每一篇文章对应该代码仓库中的 一个Issues,Issues中的评论对应你的博客每篇文章中的评论。如果你是用github的博客的话 用起来将会十分的方便。 **注册github应用** 首先需要在这注册一个*OAuth Application*, [请戳此处](https://github.com/settings/applications/new)。在注册的过程中,你需要输入以下的东西:
Application name 随意就好
Homepage URL 你的博客地址,例如https://detectivehlh.github.io/
Application description 随意就好
Authorization callback URL 也是博客地址,例如https://detectivehlh.github.io/
输入完成之后,点击注册就OK了。成功之后就会拿到*Client ID*和*Client Secret*,然后先进行一下步,暂时还不会用到这个。 **修改主题配置文件** 下一步就是要修改你的博客所使用的主题的配置文件。定位到# Comments,添加如下代码。 ```yaml gitment: enable: true mint: true count: true lazy: false cleanly: false language: github_user: detectiveHLH github_repo: detectiveHLH.github.io client_id: xxx client_secret: xxx proxy_gateway: redirect_protocol: ``` 将上面代码的github_user和github_repo改成你自己的就可以了。 **为gitment添加样式和layout** 打开你所使用的主题的目录。打开layout/_partial/comments.ejs,在原文件后加入如下代码。 ```ejs <% if(theme.gitment.enable) { %>
<% } %> ``` 将上面代码中的owner、repo、oauth中的信息换成你自己的就可以了,client_id和client_secret 就是第一步申请github应用得到的。我查了网上很多教程,都是需要点击按钮才能显示评论,我 做了一点改动,引用之后可以直接的显示评论。然后打开source/css/_partial/_gitment.styl,如果没有就新建文件。添加如下代码。 ```stylus .gitment_title:hover { color: #fff; background: #0a9caf; background-image: initial; background-position-x: initial; background-position-y: initial; background-size: initial; background-repeat-x: initial; background-repeat-y: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(10, 156, 175); } .gitment_title { border: 1px solid #0a9caf; border-top-color: rgb(10, 156, 175); border-top-style: solid; border-top-width: 1px; border-right-color: rgb(10, 156, 175); border-right-style: solid; border-right-width: 1px; border-bottom-color: rgb(10, 156, 175); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(10, 156, 175); border-left-style: solid; border-left-width: 1px; border-image-source: initial; border-image-slice: initial; border-image-width: initial; border-image-outset: initial; border-image-repeat: initial; border-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; } .gitment_title { display: inline-block; padding: 0 15px; padding-top: 0px; padding-right: 15px; padding-bottom: 0px; padding-left: 15px; color: #0a9caf; cursor: pointer; font-size: 14px; } ``` 然后打开source/css/style.styl,在原有文件后面添加如下代码,引入gitment相关的样式。 ```stylus @import "partial/_gitment.styl" ``` **结束** 到此为止,更新你的博客。就可以看到评论了。 个人博客传送门 [detectiveHLH](https://detectivehlh.github.io./) github传送门 [detectiveHLH](https://github.com/detectiveHLH)
相关文章
|
5月前
|
搜索推荐
hexo博客4:发布文章
hexo博客4:发布文章
34 0
|
5月前
|
JavaScript Shell 网络安全
hexo博客1:环境配置
hexo博客1:环境配置
59 0
|
7月前
|
Web App开发 域名解析 JavaScript
3分钟搭建个人Hexo博客
从账号的创建到一键部署,手把手教你零基础创建个人博客,后续可以继续根据网上的教程来修改代码对博客进行定制化的美化。
61 1
YI
|
9月前
|
JavaScript Shell Linux
Hexo博客搭建1
暑假在家学习时,突然感觉学过的知识忘记的很快,所以决定搭建个人博客来记录学习过程。经过前期了解后,决定采用Hexo框架来搭建个人博客。本文将记录博客搭建过程。
YI
73 0
YI
|
9月前
|
Shell 开发工具 数据安全/隐私保护
Hexo博客搭建2
上一篇介绍了博客的本地环境搭建,但这只能本地访问自己的博客。如果想让自己的博客被互联网上的其他人访问,我们还需要将博客项目进行线上部署。本文我将介绍将博客部署到github上的方法。
YI
47 0
YI
|
9月前
|
Shell
Hexo博客搭建3
之前的文章介绍了博客的本地搭建和线上部署。因为hexo的内置主题不够好看,所以我们可以选择加载其他主题来美化我们的博客页面。本文我将介绍基于hexo框架搭建的博客如何修改主题。
YI
45 0
|
10月前
|
JavaScript 搜索推荐 程序员
使用Hexo 搭建你的技术博客
使用Hexo 搭建你的技术博客
121 0
|
10月前
|
域名解析 JavaScript Linux
关于Hexo博客
关于Hexo博客
95 0
|
JavaScript Shell Linux
使用Hexo搭建自己的博客
之前一直在用typecho来做自己的博客,因为他操作比较简单,但是前几日修改一些配置的时候,看着满屏的php代码实在有些头疼,在朋友的推荐下,我成功的入坑了hexo,下面分享一些自己搭建博客的过程,尽量让读者避开一些坑。
|
JavaScript 安全 应用服务中间件

热门文章

最新文章