Skip to content

Commit

Permalink
feat(hexo): add widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
ourai committed Mar 30, 2023
1 parent b4ed72c commit f95f421
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ src/jekyll/_knosys/
src/jekyll/_assets/*/ksio/
src/jekyll/_site/

src/hexo/source/_data/knosys/
src/hexo/source/knosys/
src/hexo/source/_posts/
src/hexo/themes/lime/source/*/ksio/
src/hexo/Thumbs.db
src/hexo/db.json
Expand Down
6 changes: 3 additions & 3 deletions src/hexo/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ timezone: Asia/Shanghai

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: http:https://example.com
url: https:https://ourai.github.io/lime
root: /lime/
permalink: posts/:title/
permalink_defaults:
pretty_urls:
trailing_index: false # Set to false to remove trailing 'index.html' from permalinks
trailing_html: true # Set to false to remove trailing '.html' from permalinks
trailing_index: false
trailing_html: false

# Directory
source_dir: source
Expand Down
4 changes: 2 additions & 2 deletions src/hexo/themes/lime/layout/_ksio/layouts/page.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
</ul>
</nav>
<% } %>
<% if (page.comments === true) { %>
<% if (theme.social && theme.social.comment && page.comments === true) { %>
<!-- 评论区 -->
<div class="Article-comments col-md-9"><!--% include ksio/widgets/disqus.html %--></div>
<div class="Article-comments col-md-9"><%- partial('_ksio/widgets/comment') %></div>
<% } %>
</article>
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/hexo/themes/lime/layout/_ksio/widgets/comment.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% if (theme.social && theme.social.comment) { %>
<% if (theme.social.comment.disqus) { %>
<%- partial('_ksio/widgets/disqus') %>
<% } %>
<% } %>
42 changes: 42 additions & 0 deletions src/hexo/themes/lime/layout/_ksio/widgets/disqus.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<% const comment_config = theme.social && theme.social.comment && theme.social.comment.disqus %>
<% const disqus_shortname = comment_config && env.env === 'production' ? comment_config.shortname : '' %>
<% if (comment_config && disqus_shortname) { %>
<% const page_url = page.permalink %>
<% const page_id = page_url.replace(config.url, '') %>
<div id="disqus_thread"></div>
<% if (comment_config.proxy) { %>
<%- js('javascripts/ksio/vendors/disqusjs.min') %>
<script>
var dsqjs = new DisqusJS({
shortname: '<%= disqus_shortname %>',
siteName: '<%= config.title %>',
identifier: '<%= page_id %>',
url: '<%= page_url %>',
title: '<%= page.title %>',
api: '<%= comment_config.proxy.endpoint %>',
apikey: '<%= comment_config.proxy.key %>',
admin: '<%= comment_config.username %>',
adminLabel: '<%= comment_config.label || "管理员" %>'
});
</script>
<% } else { %>
<script>
var disqus_config = function () {
this.page.link = '<%= page_url %>';
this.page.identifier = "<%= page_id %>";
this.page.title = '<%= page.title %>';
};
(function() {
var d = document, s = d.createElement('script');
s.src = '//<%= disqus_shortname %>.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" rel="external ">comments powered by Disqus.</a></noscript>
<script id="dsq-count-scr" src="//<%= disqus_shortname %>.disqus.com/count.js" async></script>
<% } %>
<% } %>
8 changes: 8 additions & 0 deletions src/hexo/themes/lime/layout/_ksio/widgets/share.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% if (site.ksio.social.share !== false) { %>
<div class="Widget Widget--share">
<div class="Widget-body">
<p>分享到<i class="fa fa-share-alt"></i></p>
<div class="social-share" data-sites="wechat,weibo,twitter"></div>
</div>
</div>
<% } %>
6 changes: 6 additions & 0 deletions src/hexo/themes/lime/layout/_ksio/widgets/toc.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<section class="Widget Widget--toc">
<div class="Widget-header">
<h2 class="Widget-title">目录</h2>
</div>
<div class="Widget-body"></div>
</section>
6 changes: 3 additions & 3 deletions src/jekyll/_includes/ksio/widgets/disqus.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
{% else %}
<script>
var disqus_config = function () {
this.page.url = "http:https://" + location.host + "{{ page.url }}";
this.page.identifier = "{{ page.url }}";
this.page.title = "{{ page.title }}";
this.page.url = 'http:https://' + location.host + '{{ page.url }}';
this.page.identifier = '{{ page.url }}';
this.page.title = '{{ page.title }}';
};

(function() {
Expand Down

0 comments on commit f95f421

Please sign in to comment.