Skip to content

Commit

Permalink
✨ 支持 Cusdis 评论插件
Browse files Browse the repository at this point in the history
  • Loading branch information
TennyZhuang authored and zkqiang committed May 13, 2021
1 parent 2a32f61 commit 0a7f93b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
13 changes: 11 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ post:
enable: false
# 指定的插件,需要同时设置对应插件的必要参数
# The specified plugin needs to set the necessary parameters at the same time
# Options: utterances | disqus | gitalk | valine | waline | changyan | livere | remark42 | twikoo
# Options: utterances | disqus | gitalk | valine | waline | changyan | livere | remark42 | twikoo | cusdis
type: disqus


Expand Down Expand Up @@ -756,6 +756,15 @@ twikoo:
region: ap-shanghai
path: window.location.pathname

# Cusdis
# 基于第三方服务或自托管服务
# Based on third-party or self-hosted service
# See https://cusdis.com
cusdis:
host:
appID:
lang: zh-cn

#---------------------------
# 归档页
# Archive Page
Expand Down Expand Up @@ -909,7 +918,7 @@ links:
enable: false
# 指定的插件,需要同时设置对应插件的必要参数
# The specified plugin needs to set the necessary parameters at the same time
# Options: utterances | disqus | gitalk | valine | waline | changyan | livere | remark42 | twikoo
# Options: utterances | disqus | gitalk | valine | waline | changyan | livere | remark42 | twikoo | cusdis
type: disqus


Expand Down
24 changes: 24 additions & 0 deletions layout/_partial/comments/cusdis.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<% if (theme.cusdis.host && theme.cusdis.appID) { %>
<div class="cusdis" style="width:100%">
<div id="cusdis_thread"
data-host="<%= theme.cusdis.host %>"
data-app-id="<%= theme.cusdis.appID %>"
data-page-id="<%= md5(page.path) %>"
data-page-url="<%= page.path %>"
data-page-title="<%= page.title %>"
data-theme="<%= theme.dark_mode.default %>"
>
</div>
</div>
<script type="text/javascript">
Fluid.utils.loadComments('#cusdis_thread', function() {
Fluid.utils.createScript('<%= url_join(theme.cusdis.host, 'js/cusdis.es.js') %>');
Fluid.utils.createScript('<%= url_join(theme.cusdis.host, `/js/widget/lang/${ theme.cusdis.lang }.js`) %>');
var schema = document.documentElement.getAttribute('data-user-color-scheme');
if (schema) {
document.querySelector('#cusdis_thread').dataset.theme = schema
}
});
</script>
<noscript>Please enable JavaScript to view the comments</noscript>
<% } %>
5 changes: 5 additions & 0 deletions source/js/color-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@
window.REMARK42.changeTheme(schema);
}

// 设置 cusdis 评论主题
if (window.CUSDIS) {
window.CUSDIS.setTheme(schema);
}

// 设置 utterances 评论主题
var utterances = document.querySelector('iframe');
if (utterances) {
Expand Down

0 comments on commit 0a7f93b

Please sign in to comment.