Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增对Valine评论系统的支持 #646

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ Yilia 是为 [hexo](https://github.com/tommy351/hexo) 2.4+制作的主题。

## 一、外观

####**常规**
#### **常规**

![常规](https://cloud.githubusercontent.com/assets/2024949/19027861/92879edc-8967-11e6-8e60-7987b6507c8d.gif)

####**手机**
#### **手机**

![手机](https://cloud.githubusercontent.com/assets/2024949/19027020/1c5b756a-895f-11e6-99bf-ddff9687aee0.gif)

####**ipad横竖屏切换**
#### **ipad横竖屏切换**

![ipad横竖屏切换](https://cloud.githubusercontent.com/assets/2024949/19026392/e74e1816-8957-11e6-8f08-eac9b3c8c036.gif)

Expand Down Expand Up @@ -79,7 +79,7 @@ git pull
主题配置文件在主目录下的`_config.yml`,请根据自己需要修改使用。
完整配置例子,可以参考[我的博客备份](https://github.com/litten/BlogBackup)

```
```yaml
# Header

menu:
Expand Down Expand Up @@ -155,7 +155,7 @@ avatar:
#是否开启分享
share_jia: true

#评论:1、多说;2、网易云跟帖;3、畅言;4、Disqus;5、Gitment
#评论:1、多说;2、网易云跟帖;3、畅言;4、Disqus;5、Gitment;6、Valine
#不需要使用某项,直接设置值为false,或注释掉
#具体请参考wiki:https://github.com/litten/hexo-theme-yilia/wiki/

Expand All @@ -179,6 +179,15 @@ gitment_oauth:
client_id: '' #client ID
client_secret: '' #client secret

#6、Valine https://valine.js.org
valine:
appid: #Leancloud应用的appId
appkey: #Leancloud应用的appKey
verify: false #验证码
notify: false #评论回复提醒
avatar: mm #评论列表头像样式:''/mm/identicon/monsterid/wavatar/retro/hide
placeholder: Just go go #评论框占位符

# 样式定制 - 一般不需要修改,除非有很强的定制欲望…
style:
# 头像上面的背景颜色
Expand Down
14 changes: 12 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ google_analytics: ''
favicon: /favicon.png

#你的头像url
avatar:
avatar:

#是否开启分享
share_jia: true

#评论:1、多说;2、网易云跟帖;3、畅言;4、Disqus;5、Gitment
#评论:1、多说;2、网易云跟帖;3、畅言;4、Disqus;5、Gitment;6、Valine
#不需要使用某项,直接设置值为false,或注释掉
#具体请参考wiki:https://github.com/litten/hexo-theme-yilia/wiki/

Expand All @@ -97,6 +97,16 @@ gitment_oauth:
client_id: '' #client ID
client_secret: '' #client secret

#6、Valine https://valine.js.org
valine:
appid: #Leancloud应用的appId
appkey: #Leancloud应用的appKey
verify: false #验证码
notify: false #评论回复提醒
avatar: mm #评论列表头像样式:''/mm/identicon/monsterid/wavatar/retro/hide
placeholder: Just go go #评论框占位符


# 样式定制 - 一般不需要修改,除非有很强的定制欲望…
style:
# 头像上面的背景颜色
Expand Down
12 changes: 12 additions & 0 deletions layout/_partial/article.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,16 @@
url: config.url+url_for(post.path)
}) %>
<% } %>



<% 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>
<% } %>
<% } %>
17 changes: 17 additions & 0 deletions layout/_partial/post/valine.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div id="vcomment" class="comment"></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>
var notify = '<%= theme.valine.notify %>' == true ? true : false;
var verify = '<%= theme.valine.verify %>' == true ? true : false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样写会导致 notify、verify 永远为 false,应改为:

  var notify = '<%= theme.valine.notify %>' == 'true' ? true : false;
  var verify = '<%= theme.valine.verify %>' == 'true' ? true : false;


new Valine({
el: '#vcomment',
notify: notify,
verify: verify,
app_id: "<%= theme.valine.appid %>",
app_key: "<%= theme.valine.appkey %>",
placeholder: "<%= theme.valine.placeholder %>",
avatar:"<%= theme.valine.avatar %>"
});
</script>