Skip to content

Commit

Permalink
feat: add Valine comment system
Browse files Browse the repository at this point in the history
  • Loading branch information
kitian616 committed Dec 9, 2018
1 parent 20fdbb4 commit 9b0656f
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 30 deletions.
11 changes: 6 additions & 5 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ sharing:
## => Comments
##############################
comments:
provider: false # false (default), "disqus", "gitalk", "custom"
provider: false # false (default), "disqus", "gitalk", "valine", "custom"

## Disqus
disqus:
Expand All @@ -134,10 +134,11 @@ comments:

## Valine
# please refer to https://valine.js.org/en/index.html for more info.
custom:
API_ID : # LeanCloud App id
API_Key : # LeanCloud App key
placeholder: Just Go Go. # Prompt information
valine:
app_id : # LeanCloud App id
app_key : # LeanCloud App key
placeholder : # Prompt information


## => Pageview
##############################
Expand Down
2 changes: 2 additions & 0 deletions _data/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ sources:
gitalk:
js: 'https://cdn.bootcss.com/gitalk/1.2.2/gitalk.min.js'
css: 'https://cdn.bootcss.com/gitalk/1.2.2/gitalk.min.css'
valine: 'https://unpkg.com/valine/dist/Valine.min.js' # bootcdn not available
mathjax: 'https://cdn.bootcss.com/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_CHTML'
mermaid: 'https://cdn.bootcss.com/mermaid/8.0.0-rc.8/mermaid.min.js'
unpkg:
Expand All @@ -56,5 +57,6 @@ sources:
gitalk:
js: 'https://unpkg.com/gitalk@1.2.2/dist/gitalk.min.js'
css: 'https://unpkg.com/gitalk@1.2.2/dist/gitalk.css'
valine: 'https//unpkg.com/valine/dist/Valine.min.js'
mathjax: 'https://unpkg.com/mathjax@2.7.4/unpacked/MathJax.js?config=TeX-MML-AM_CHTML'
mermaid: 'https://unpkg.com/mermaid@8.0.0-rc.8/dist/mermaid.min.js'
22 changes: 0 additions & 22 deletions _includes/comments-providers/custom.html

This file was deleted.

33 changes: 33 additions & 0 deletions _includes/comments-providers/valine.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{%- include snippets/get-sources.html -%}
{%- assign _sources = __return -%}

{%- 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 -%}


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

<div id="vcomments"></div>
<script>
window.Lazyload.js(['{{ _sources.leancloud_js_sdk}}', '{{ _sources.valine }}'], function() {
var _config = {
el: '#vcomments',
appId: '{{ _VALINE_APP_ID }}',
appKey: '{{ _VALINE_APP_KEY }}',
verify: true,
};
{%- if _VALINE_PLACEHOLDER -%}
_config.placeholder = '{{ _VALINE_PLACEHOLDER }}';
{%- endif -%}
{%- assign _page_lang_slice = page.lang | slice: 0, 2 -%}
{%- if _page_lang_slice != 'zh' -%}
_config.lang = 'en';
{%- endif -%}
new Valine(_config);
});
</script>

{%- endif -%}
2 changes: 2 additions & 0 deletions _includes/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
{%- include comments-providers/disqus.html -%}
{%- elsif site.comments.provider == 'gitalk' -%}
{%- include comments-providers/gitalk.html -%}
{%- elsif site.comments.provider == 'valine' -%}
{%- include comments-providers/valine.html -%}
{%- elsif site.comments.provider == 'custom' -%}
{%- include comments-providers/custom.html -%}
{%- endif -%}
Expand Down
1 change: 1 addition & 0 deletions _includes/scripts/variables.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
js: '{{ _sources.gitalk.js }}',
css: '{{ _sources.gitalk.css }}'
},
valine: '{{ _sources.valine }}',
mathjax: '{{ _sources.mathjax }}',
mermaid: '{{ _sources.mermaid }}'
},
Expand Down
9 changes: 8 additions & 1 deletion docs/_config.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ sharing:
## => Comments
##############################
comments:
provider: false # false (default), "disqus", "gitalk", "custom"
provider: false # false (default), "disqus", "gitalk", "valine", "custom"

## Disqus
disqus:
Expand All @@ -133,6 +133,13 @@ comments:
admin: # GitHub repo owner and collaborators, only these guys can initialize GitHub issues, IT IS A LIST.
# - your GitHub Id

## Valine
# please refer to https://valine.js.org/en/index.html for more info.
valine:
app_id : # LeanCloud App id
app_key : # LeanCloud App key
placeholder : # Prompt information


## => Pageview
##############################
Expand Down
10 changes: 9 additions & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ sharing:
## => Comments
##############################
comments:
provider: gitalk # false (default), "disqus", "gitalk", "custom"
provider: gitalk # false (default), "disqus", "gitalk", "valine", "custom"
# provider: valine

## Disqus
disqus:
Expand All @@ -134,6 +135,13 @@ comments:
admin:
- kitian616

## Valine
# please refer to https://valine.js.org/en/index.html for more info.
valine:
app_id : uAG3OhdcH8H4fxSqXLyBljA7-gzGzoHsz
app_key : Mzf5m9skSwYVWVXhGiYMNyXs
placeholder : # Prompt information


## => Pageview
##############################
Expand Down
2 changes: 2 additions & 0 deletions docs/_data/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ sources:
gitalk:
js: 'https://cdn.bootcss.com/gitalk/1.2.2/gitalk.min.js'
css: 'https://cdn.bootcss.com/gitalk/1.2.2/gitalk.min.css'
valine: 'https://unpkg.com/valine/dist/Valine.min.js' # bootcdn not available
mathjax: 'https://cdn.bootcss.com/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_CHTML'
mermaid: 'https://cdn.bootcss.com/mermaid/8.0.0-rc.8/mermaid.min.js'
unpkg:
Expand All @@ -56,5 +57,6 @@ sources:
gitalk:
js: 'https://unpkg.com/gitalk@1.2.2/dist/gitalk.min.js'
css: 'https://unpkg.com/gitalk@1.2.2/dist/gitalk.css'
valine: 'https//unpkg.com/valine/dist/Valine.min.js'
mathjax: 'https://unpkg.com/mathjax@2.7.4/unpacked/MathJax.js?config=TeX-MML-AM_CHTML'
mermaid: 'https://unpkg.com/mermaid@8.0.0-rc.8/dist/mermaid.min.js'
9 changes: 8 additions & 1 deletion test/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ sharing:
## => Comments
##############################
comments:
provider: false # false (default), "disqus", "gitalk", "custom"
provider: false # false (default), "disqus", "gitalk", "valine", "custom"

## Disqus
disqus:
Expand All @@ -132,6 +132,13 @@ comments:
admin: # GitHub repo owner and collaborators, only these guys can initialize GitHub issues, IT IS A LIST.
# - your GitHub Id

## Valine
# please refer to https://valine.js.org/en/index.html for more info.
valine:
app_id : # LeanCloud App id
app_key : # LeanCloud App key
placeholder : # Prompt information


## => Pageview
##############################
Expand Down
2 changes: 2 additions & 0 deletions test/_data/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ sources:
gitalk:
js: 'https://cdn.bootcss.com/gitalk/1.2.2/gitalk.min.js'
css: 'https://cdn.bootcss.com/gitalk/1.2.2/gitalk.min.css'
valine: 'https://unpkg.com/valine/dist/Valine.min.js' # bootcdn not available
mathjax: 'https://cdn.bootcss.com/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_CHTML'
mermaid: 'https://cdn.bootcss.com/mermaid/8.0.0-rc.8/mermaid.min.js'
unpkg:
Expand All @@ -56,5 +57,6 @@ sources:
gitalk:
js: 'https://unpkg.com/gitalk@1.2.2/dist/gitalk.min.js'
css: 'https://unpkg.com/gitalk@1.2.2/dist/gitalk.css'
valine: 'https//unpkg.com/valine/dist/Valine.min.js'
mathjax: 'https://unpkg.com/mathjax@2.7.4/unpacked/MathJax.js?config=TeX-MML-AM_CHTML'
mermaid: 'https://unpkg.com/mermaid@8.0.0-rc.8/dist/mermaid.min.js'

0 comments on commit 9b0656f

Please sign in to comment.