Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
Add support for DUOSHUO comment, fixes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
gallenhu committed Dec 1, 2016
1 parent 4445b61 commit 815154f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
14 changes: 14 additions & 0 deletions layout/_partial/after-footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,18 @@
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<% } else if (config.duoshuo_shortname) { %>
<!-- 多说公共JS代码 start (一个网页只需插入一次) -->
<script type="text/javascript">
var duoshuoQuery = {short_name:'<%= config.duoshuo_shortname %>'};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- 多说公共JS代码 end -->
<% } %>
8 changes: 6 additions & 2 deletions layout/_partial/comment.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
<script type="text/javascript">
var disqus_config = function () {
this.page.url = window.location.href;
this.page.identifier = 'a unique identifier for each page where Disqus is present';
this.page.title = 'a unique title for each page where Disqus is present';
this.page.identifier = '<%= page.layout %>-<%= page.slug %>';
this.page.title = '<%= page.title %>';
};
</script>
<noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
<% } else if (config.duoshuo_shortname) { %>
<!-- 多说评论框 start -->
<div class="ds-thread" data-thread-key="<%= page.layout %>-<%= page.slug %>" data-title="<%= page.title %>" data-url="<%= page.permalink %>"></div>
<!-- 多说评论框 end -->
<% } %>
</section>
<% } %>
8 changes: 3 additions & 5 deletions layout/post.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@
</div>
<!-- Comments -->
<div class="container">
<% if (config.disqus_shortname) { %>
<%- partial('_partial/comment', {
shortname: config.disqus_shortname
}) %>
<% } %>
<%- partial('_partial/comment', {
shortname: config.disqus_shortname
}) %>
</div>
<!-- Pre or Next -->
<div class="nav-links">
Expand Down
10 changes: 10 additions & 0 deletions source/css/_comment.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#comment #ds-thread #ds-reset a.ds-like-thread-button {
background-color: #fff;
background-image: none;
}
#comment #ds-reset .ds-gradient-bg {
background: none;
}
#comment #ds-thread #ds-reset .ds-powered-by {
display: none;
}
1 change: 1 addition & 0 deletions source/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
@import './post';
@import './highlight';
@import './archive';
@import './comment';

@import './mobile';

0 comments on commit 815154f

Please sign in to comment.