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

[Feature] Add support for Vssue comment system #157

Merged
merged 5 commits into from
Jul 26, 2021
Merged
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ the DoIt theme may be more suitable for you.
* **Commento** comment system supported by [Commento](https://commento.io/)
* **Utterances** comment system supported by [Utterances](https://utteranc.es/)
* **Twikoo** comment system supported by [Twikoo](https://twikoo.js.org/)
* **Vssue** comment system supported by [Vssue](https://vssue.js.org/)

### Extended Features

Expand Down Expand Up @@ -207,6 +208,7 @@ Thanks to the authors of following resources included in the theme:
* [Valine](https://valine.js.org/)
* [Waline](https://waline.js.org/)
* [Twikoo](https://twikoo.js.org/)
* [Vssue](https://vssue.js.org/)
* [cookieconsent](https://github.com/osano/cookieconsent)
* [Pjax](https://github.com/PaperStrike/Pjax)
* [Topbar](https://github.com/buunguyen/topbar)
Expand Down
2 changes: 2 additions & 0 deletions README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ DoIt 主题增加了许多新的功能与配置项,查看[变更日志](https:
* 支持 **[Commento](https://commento.io/)** 评论系统
* 支持 **[Utterances](https://utteranc.es/)** 评论系统
* 支持 **[Twikoo](https://twikoo.js.org/)** 评论系统
* 支持 **[Vssue](https://vssue.js.org/)** 评论系统

### 扩展功能

Expand Down Expand Up @@ -204,6 +205,7 @@ DoIt 主题中用到了以下项目,感谢它们的作者:
* [Valine](https://valine.js.org/)
* [Waline](https://waline.js.org/)
* [Twikoo](https://twikoo.js.org/)
* [Vssue](https://vssue.js.org/)
* [cookieconsent](https://github.com/osano/cookieconsent)
* [Pjax](https://github.com/PaperStrike/Pjax)
* [Topbar](https://github.com/buunguyen/topbar)
Expand Down
11 changes: 10 additions & 1 deletion assets/data/cdn/jsdelivr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,13 @@ libFiles:
# [email protected] https://github.com/PaperStrike/Pjax
pjaxJS: "@sliphua/[email protected]/dist/pjax.min.js"
# [email protected] https://github.com/buunguyen/topbar
topbarJS: [email protected]/topbar.min.js
topbarJS: [email protected]/topbar.min.js
# [email protected] https://vuejs.org
vueRuntimeJS: [email protected]/dist/vue.runtime.min.js
# [email protected] https://vssue.js.org
vssueBitbucketJS: [email protected]/dist/vssue.bitbucket.min.js
vssueGiteaJS: [email protected]/dist/vssue.gitea.min.js
vssueGiteeJS: [email protected]/dist/vssue.gitee.min.js
vssueGithubJS: [email protected]/dist/vssue.github.min.js
vssueGitlabJS: [email protected]/dist/vssue.gitlab.min.js
vssueCSS: [email protected]/dist/vssue.min.css
2 changes: 1 addition & 1 deletion assets/js/theme.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/theme.min.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions assets/lib/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ [email protected] https://github.com/twitter/twemoji
[email protected] https://twikoo.js.org
[email protected] https://github.com/alexmacarthur/typeit
[email protected] https://valine.js.org
[email protected] https://vssue.js.org
[email protected] https://vuejs.org
[email protected] https://waline.js.org
30 changes: 30 additions & 0 deletions assets/lib/vssue/vssue.bitbucket.min.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions assets/lib/vssue/vssue.gitea.min.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions assets/lib/vssue/vssue.gitee.min.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions assets/lib/vssue/vssue.github.min.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions assets/lib/vssue/vssue.gitlab.min.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions assets/lib/vssue/vssue.min.css

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions assets/lib/vue/vue.runtime.min.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,15 @@ enableEmoji = true
region = ""
path = ""
visitor = true
# Vssue comment config (https://vssue.js.org//)
# Vssue comment 评论系统设置 (https://vssue.js.org//)
[params.page.comment.vssue]
enable = false
platform = "" # ("bitbucket", "gitea", "gitee", "github", "gitlab")
owner = ""
repo = ""
clientId = ""
clientSecret = ""
# Third-party library config
# 第三方库配置
[params.page.library]
Expand Down
2 changes: 2 additions & 0 deletions exampleSite/content/about/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ math:
* :(fas fa-comment-dots fa-fw): **Commento** comment system supported by [Commento](https://commento.io/)
* :(fas fa-comment-alt fa-fw): **Utterances** comment system supported by [Utterances](https://utteranc.es/)
* :(fas fa-comment-alt fa-fw): **Twikoo** comment system supported by [Twikoo](https://twikoo.js.org/)
* :(fas fa-comment-alt fa-fw): **Vssue** comment system supported by [Vssue](https://vssue.js.org/)

#### Extended Features

Expand Down Expand Up @@ -108,6 +109,7 @@ Thanks to the authors of following resources included in the theme:
* [Valine](https://valine.js.org/)
* [Waline](https://waline.js.org/)
* [Twikoo](https://twikoo.js.org/)
* [Vssue](https://vssue.js.org/)
* [cookieconsent](https://github.com/osano/cookieconsent)
* [Pjax](https://github.com/PaperStrike/Pjax)
* [Topbar](https://github.com/buunguyen/topbar)
2 changes: 2 additions & 0 deletions exampleSite/content/about/index.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ math:
* :(fas fa-comment-dots fa-fw): 支持 **[Commento](https://commento.io/)** 评论系统
* :(far fa-comment-alt fa-fw): 支持 **[Utterances](https://utteranc.es/)** 评论系统
* :(far fa-comment-alt fa-fw): 支持 **[Twikoo](https://twikoo.js.org/)** 评论系统
* :(far fa-comment-alt fa-fw): 支持 **[Vssue](https://vssue.js.org/)** 评论系统

#### 扩展功能

Expand Down Expand Up @@ -108,6 +109,7 @@ DoIt 主题中用到了以下项目,感谢它们的作者:
* [Valine](https://valine.js.org/)
* [Waline](https://waline.js.org/)
* [Twikoo](https://twikoo.js.org/)
* [Vssue](https://vssue.js.org/)
* [cookieconsent](https://github.com/osano/cookieconsent)
* [Pjax](https://github.com/PaperStrike/Pjax)
* [Topbar](https://github.com/buunguyen/topbar)
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,14 @@ Please open the code block below to view the complete sample configuration :(far
region = ""
path = ""
visitor = true
# {{< version 0.2.12 >}} {{< link "https://vssue.js.org/" "Vssue" >}} comment config
[params.page.comment.vssue]
enable = false
platform = "" # ("bitbucket", "gitea", "gitee", "github", "gitlab")
owner = ""
repo = ""
clientId = ""
clientSecret = ""
# {{< version 0.2.7 >}} Third-party library config
[params.page.library]
[params.page.library.css]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,14 @@ hugo
region = ""
path = ""
visitor = true
# {{< version 0.2.12 >}} {{< link "https://vssue.js.org/" "Vssue" >}} 评论系统设置
[params.page.comment.vssue]
enable = false
platform = "" # ("bitbucket", "gitea", "gitee", "github", "gitlab")
owner = ""
repo = ""
clientId = ""
clientSecret = ""
# {{< version 0.2.7 >}} 第三方库配置
[params.page.library]
[params.page.library.css]
Expand Down
42 changes: 42 additions & 0 deletions layouts/partials/comment.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,48 @@
Please enable JavaScript to view the comments powered by <a href="https://twikoo.js.org/">Twikoo</a>.
</noscript>
{{- end -}}

{{- /* Vssue Comment System */ -}}
{{- $vssue := $comment.vssue | default dict -}}
{{- if $vssue.enable -}}
<div id="vssue"></div>
{{- $source := $cdn.vssueCSS | default "lib/vssue/vssue.min.css" -}}
{{- dict "Source" $source "Minify" true "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxStyle.html" -}}
{{- $source := $cdn.vueRuntimeJS | default "lib/vue/vue.runtime.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}}
{{- if eq $vssue.platform "bitbucket" -}}
{{- $source := $cdn.vssueBitbucketJS | default "lib/vssue/vssue.bitbucket.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}}
{{- else if eq $vssue.platform "gitea" -}}
{{- $source := $cdn.vssueGiteaJS | default "lib/vssue/vssue.gitea.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}}
{{- else if eq $vssue.platform "gitee" -}}
{{- $source := $cdn.vssueGiteeJS | default "lib/vssue/vssue.gitee.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}}
{{- else if eq $vssue.platform "github" -}}
{{- $source := $cdn.vssueGithubJS | default "lib/vssue/vssue.github.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}}
{{- else if eq $vssue.platform "gitlab" -}}
{{- $source := $cdn.vssueGitlabJS | default "lib/vssue/vssue.gitlab.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}}
{{- end -}}
{{- $commentConfig = dict "el" "#vssue" "title" .Title | dict "vssue" | merge $commentConfig -}}
{{- with $vssue.owner -}}
{{- $commentConfig = dict "owner" . | dict "vssue" | merge $commentConfig -}}
{{- end -}}
{{- with $vssue.repo -}}
{{- $commentConfig = dict "repo" . | dict "vssue" | merge $commentConfig -}}
{{- end -}}
{{- with $vssue.clientId -}}
{{- $commentConfig = dict "clientId" . | dict "vssue" | merge $commentConfig -}}
{{- end -}}
{{- with $vssue.clientSecret -}}
{{- $commentConfig = dict "clientSecret" . | dict "vssue" | merge $commentConfig -}}
{{- end -}}
<noscript>
Please enable JavaScript to view the comments powered by <a href="https://vssue.js.org/">Vssue</a>.
</noscript>
{{- end -}}
</div>
{{- end -}}

Expand Down
17 changes: 17 additions & 0 deletions src/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,23 @@ function initComment() {
});
window.switchThemeEventSet.add(window._utterancesOnSwitchTheme);
}
if (window.config.comment.vssue) {
let vssue = window.config.comment.vssue;
new Vue({
el: vssue.el,
render: h => h('Vssue', {
props: {
title: vssue.title,
options: {
owner: vssue.owner,
repo: vssue.repo,
clientId: vssue.clientId,
clientSecret: vssue.clientSecret,
},
}
})
})
}
}
}

Expand Down