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

feat: 新增 Artalk 评论系统 #1142

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 10 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,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 | cusdis | giscus | discuss
# Options: utterances | disqus | gitalk | valine | waline | changyan | livere | remark42 | twikoo | cusdis | giscus | discuss | artalk
type: disqus


Expand Down Expand Up @@ -912,6 +912,13 @@ discuss:
serverURLs:
path: window.location.pathname

# Artalk
# 由 Golang 驱动的自托管评论系统
# Self-hosted commenting system driven by Golang
# See: https://artalk.js.org
artalk:
server:
site:

#---------------------------
# 归档页
Expand Down Expand Up @@ -1124,6 +1131,8 @@ static_prefix:

discuss: https://lib.baomitu.com/discuss/1.2.1/

artalk: https://lib.baomitu.com/artalk/2.9.0/

hint: https://lib.baomitu.com/hint.css/2.7.0/

moment: https://lib.baomitu.com/moment.js/2.29.4/
45 changes: 45 additions & 0 deletions layout/_partials/comments/artalk.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<% if (theme.artalk && theme.artalk.server) { %>
<div id="artalk"></div>
<script type="text/javascript">
Fluid.utils.loadComments('#comments', function() {
Fluid.utils.createCssLink('<%= url_join(theme.static_prefix.artalk, 'Artalk.min.css') %>');
Fluid.utils.createScript('<%= url_join(theme.static_prefix.artalk, 'Artalk.min.js') %>', function() {
var schema = document.documentElement.getAttribute('data-user-color-scheme');
if (schema !== 'light' && schema !== 'dark') {
schema = 'light';
}
var options = Object.assign(
<%- JSON.stringify(theme.artalk || {}) %>,
{
el: document.querySelector('#artalk'),
pageKey: '',
pageTitle: '<%= page.title %>',
server: '<%= theme.artalk.server %>',
site: '<%= theme.artalk.site %>',
darkMode: schema === 'dark'
}
);
Artalk.init(options);

// watch for user color scheme change
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === 'data-user-color-scheme') {
var schema = document.documentElement.getAttribute('data-user-color-scheme');
if (schema === 'dark') {
Artalk.setDarkMode(true);
} else {
Artalk.setDarkMode(false);
}
}
});
});

observer.observe(document.documentElement, {
attributes: true
});
});
});
</script>
<noscript>Please enable JavaScript to view the comments</noscript>
<% } %>
Loading