Skip to content

Commit

Permalink
ui(comment): add disqus support
Browse files Browse the repository at this point in the history
  • Loading branch information
luijp committed Nov 6, 2023
1 parent 1198444 commit 2a6ad4e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
7 changes: 6 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ local_search:
# ---------------------------------------------------------------------------------------
comment:
enable: false # Option values: true | false
use: valine # Option values: valine | gitalk | twikoo | waline | giscus
use: valine # Option values: valine | gitalk | twikoo | waline | giscus | disqus

# Valine
# See: https://github.com/xCss/Valine
Expand Down Expand Up @@ -252,6 +252,11 @@ comment:
category_id:
reactions_enabled: false # Option values: true | false

# Disqus
# See: https://disqus.com/
disqus:
disqus_short_name: # Site Shortname

# ---------------------------------------------------------------------------------------
# RSS
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/rss.html
Expand Down
2 changes: 2 additions & 0 deletions layout/_partial/comment/comment.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const {
<%- partial('waline') %>
<% } else if (theme_comment_use === 'giscus') { %>
<%- partial('giscus') %>
<% } else if (theme_comment_use === 'disqus') {%>
<%- partial('disqus') %>
<% } %>
</div>
<% } %>
Expand Down
23 changes: 23 additions & 0 deletions layout/_partial/comment/disqus.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<%
const { enable: pjax_enable } = theme?.pjax || {}
const {
disqus_short_name
} = theme?.comment?.disqus || {}
%>
<% if (disqus_short_name) { %>
<div id="disqus_thread"></div>
<script>
(function() {
var d = document, s = d.createElement('script');
s.src = 'https://<%= disqus_short_name %>.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<script id="dsq-count-scr" src="//<%= disqus_short_name %>.disqus.com/count.js" async></script>
<% } else { %>
<div class="error-tips">Please fill in Disqus complete configuration items.</div>
<% } %>

0 comments on commit 2a6ad4e

Please sign in to comment.