Skip to content

Commit 0a7f93b

Browse files
TennyZhuangzkqiang
authored andcommitted
✨ 支持 Cusdis 评论插件
1 parent 2a32f61 commit 0a7f93b

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

_config.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ post:
627627
enable: false
628628
# 指定的插件,需要同时设置对应插件的必要参数
629629
# The specified plugin needs to set the necessary parameters at the same time
630-
# Options: utterances | disqus | gitalk | valine | waline | changyan | livere | remark42 | twikoo
630+
# Options: utterances | disqus | gitalk | valine | waline | changyan | livere | remark42 | twikoo | cusdis
631631
type: disqus
632632

633633

@@ -756,6 +756,15 @@ twikoo:
756756
region: ap-shanghai
757757
path: window.location.pathname
758758

759+
# Cusdis
760+
# 基于第三方服务或自托管服务
761+
# Based on third-party or self-hosted service
762+
# See https://cusdis.com
763+
cusdis:
764+
host:
765+
appID:
766+
lang: zh-cn
767+
759768
#---------------------------
760769
# 归档页
761770
# Archive Page
@@ -909,7 +918,7 @@ links:
909918
enable: false
910919
# 指定的插件,需要同时设置对应插件的必要参数
911920
# The specified plugin needs to set the necessary parameters at the same time
912-
# Options: utterances | disqus | gitalk | valine | waline | changyan | livere | remark42 | twikoo
921+
# Options: utterances | disqus | gitalk | valine | waline | changyan | livere | remark42 | twikoo | cusdis
913922
type: disqus
914923

915924

layout/_partial/comments/cusdis.ejs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<% if (theme.cusdis.host && theme.cusdis.appID) { %>
2+
<div class="cusdis" style="width:100%">
3+
<div id="cusdis_thread"
4+
data-host="<%= theme.cusdis.host %>"
5+
data-app-id="<%= theme.cusdis.appID %>"
6+
data-page-id="<%= md5(page.path) %>"
7+
data-page-url="<%= page.path %>"
8+
data-page-title="<%= page.title %>"
9+
data-theme="<%= theme.dark_mode.default %>"
10+
>
11+
</div>
12+
</div>
13+
<script type="text/javascript">
14+
Fluid.utils.loadComments('#cusdis_thread', function() {
15+
Fluid.utils.createScript('<%= url_join(theme.cusdis.host, 'js/cusdis.es.js') %>');
16+
Fluid.utils.createScript('<%= url_join(theme.cusdis.host, `/js/widget/lang/${ theme.cusdis.lang }.js`) %>');
17+
var schema = document.documentElement.getAttribute('data-user-color-scheme');
18+
if (schema) {
19+
document.querySelector('#cusdis_thread').dataset.theme = schema
20+
}
21+
});
22+
</script>
23+
<noscript>Please enable JavaScript to view the comments</noscript>
24+
<% } %>

source/js/color-schema.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@
178178
window.REMARK42.changeTheme(schema);
179179
}
180180

181+
// 设置 cusdis 评论主题
182+
if (window.CUSDIS) {
183+
window.CUSDIS.setTheme(schema);
184+
}
185+
181186
// 设置 utterances 评论主题
182187
var utterances = document.querySelector('iframe');
183188
if (utterances) {

0 commit comments

Comments
 (0)