Skip to content

Commit

Permalink
Update options of Valine
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Apr 30, 2020
1 parent 3dcd359 commit 6e6fc74
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
9 changes: 6 additions & 3 deletions _config.yml
Expand Up @@ -605,13 +605,16 @@ changyan:
# For more information: https://valine.js.org, https://github.com/xCss/Valine
valine:
enable: false
appid: # Your leancloud application appid
appkey: # Your leancloud application appkey
appId: # Your leancloud application appid
appKey: # Your leancloud application appkey
notify: false # Mail notifier
verify: false # Verification code
placeholder: Just go go # Comment box placeholder
avatar: mm # Gravatar style
guest_info: nick,mail,link # Custom comment header
meta: # Custom comment header
- nick
- mail
- link
pageSize: 10 # Pagination size
language: # Language, available values: en, zh-cn
visitor: false # Article reading statistic
Expand Down
2 changes: 1 addition & 1 deletion layout/_macro/post.njk
Expand Up @@ -97,7 +97,7 @@
{%- endif %}

{# LeanCloud PageView #}
{%- if theme.leancloud_visitors.enable or (theme.valine.enable and theme.valine.appid and theme.valine.appkey and theme.valine.visitor) %}
{%- if theme.leancloud_visitors.enable or (theme.valine.enable and theme.valine.appId and theme.valine.appKey and theme.valine.visitor) %}
<span id="{{ url_for(post.path) }}" class="post-meta-item leancloud_visitors" data-flag-title="{{ post.title }}" title="{{ __('post.views') }}">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
Expand Down
22 changes: 3 additions & 19 deletions layout/_third-party/comments/valine.njk
Expand Up @@ -3,27 +3,11 @@
<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
NexT.utils.getScript('{{ valine_uri }}', () => {
var GUEST = ['nick', 'mail', 'link'];
var guest = '{{ theme.valine.guest_info }}';
guest = guest.split(',').filter(item => {
return GUEST.includes(item);
});
new Valine({
new Valine(Object.assign({
el : '#valine-comments',
verify : {{ theme.valine.verify }},
notify : {{ theme.valine.notify }},
appId : '{{ theme.valine.appid }}',
appKey : '{{ theme.valine.appkey }}',
placeholder: {{ theme.valine.placeholder | json }},
avatar : '{{ theme.valine.avatar }}',
meta : guest,
pageSize : '{{ theme.valine.pageSize }}' || 10,
visitor : {{ theme.valine.visitor }},
lang : '{{ theme.valine.language }}' || 'zh-cn',
path : location.pathname,
recordIP : {{ theme.valine.recordIP }},
serverURLs : '{{ theme.valine.serverURLs }}'
});
}, {{ theme.valine | json }}
));
}, window.Valine);
});
</script>
4 changes: 2 additions & 2 deletions scripts/filters/comment/valine.js
Expand Up @@ -8,7 +8,7 @@ const { iconText } = require('./common');
// Add comment
hexo.extend.filter.register('theme_inject', injects => {
let theme = hexo.theme.config;
if (!theme.valine.enable || !theme.valine.appid || !theme.valine.appkey) return;
if (!theme.valine.enable || !theme.valine.appId || !theme.valine.appKey) return;

injects.comment.raw('valine', '<div class="comments" id="valine-comments"></div>', {}, {cache: true});

Expand All @@ -19,7 +19,7 @@ hexo.extend.filter.register('theme_inject', injects => {
// Add post_meta
hexo.extend.filter.register('theme_inject', injects => {
let theme = hexo.theme.config;
if (!theme.valine.enable || !theme.valine.appid || !theme.valine.appkey) return;
if (!theme.valine.enable || !theme.valine.appId || !theme.valine.appKey) return;

injects.postMeta.raw('valine', `
{% if post.comments and (is_post() or theme.valine.comment_count) %}
Expand Down

0 comments on commit 6e6fc74

Please sign in to comment.