Skip to content

Commit

Permalink
valine-visitor&config
Browse files Browse the repository at this point in the history
  • Loading branch information
zerone01y committed Feb 1, 2019
1 parent 647fb2a commit cc323eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ comments:
app_id : # LeanCloud App id
app_key : # LeanCloud App key
placeholder : # Prompt information
visitor : # false (default)
meta : # "[nick, mail, link]" (default) nickname, E-mail, Personal-site


## => Pageview
Expand Down
17 changes: 15 additions & 2 deletions _includes/comments-providers/valine.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@
{%- assign _VALINE_APP_ID = site.comments.valine.app_id -%}
{%- assign _VALINE_APP_KEY = site.comments.valine.app_key -%}
{%- assign _VALINE_PLACEHOLDER = site.comments.valine.placeholder -%}
{%- assign _VALINE_VISITOR = site.comments.valine.visitor -%}
{%- assign _VALINE_META = site.comments.valine.meta -%}


{%- if page.key and
_VALINE_APP_ID and
{%- if _VALINE_APP_ID and
_VALINE_APP_KEY -%}

<div id="vcomments"></div>

{%- if _VALINE_VISITOR -%}
<span id="{{page.url}}" class="leancloud-visitors" data-flag-title={{page.title}}>
</span>
{%- endif -%}

<script>
window.Lazyload.js(['{{ _sources.leancloud_js_sdk}}', '{{ _sources.valine }}'], function() {
var _config = {
Expand All @@ -25,6 +32,12 @@
{%- assign _page_lang_slice = page.lang | slice: 0, 2 -%}
{%- if _page_lang_slice != 'zh' -%}
_config.lang = 'en';
{%- endif -%}
{%- if _VALINE_VISITOR -%}
_config.visitor = 'true';
{%- endif -%}
{%- if _VALINE_META -%}
_config.meta = {{ _VALINE_META}};
{%- endif -%}
new Valine(_config);
});
Expand Down

0 comments on commit cc323eb

Please sign in to comment.