Skip to content

Commit 8a1c23c

Browse files
committed
share
1 parent eb69d98 commit 8a1c23c

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

_config.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ services:
2626
busuanzi: true
2727
# fastclick: true
2828
# leancloud_visitors: true
29-
recommended_posts: true # 需要安装"hexo-recommended-posts": "^1.0.3",
29+
recommended_posts: true # 需要安装插件 hexo-recommended-posts
3030
comments: true
3131
volantis: true
3232
music: true
3333
share: true
34+
qrcode: true # 需要安装插件 npm i -S hexo-helper-qrcode
3435

3536

3637
############################### 杂项 ###############################
@@ -52,6 +53,8 @@ music:
5253
links: true # layout: links 的页面是否显示
5354
post: true # layout: post 的页面是否显示
5455

56+
57+
5558
# 友链页头像占位图
5659
loading_img: https://cdn.jsdelivr.net/gh/xaoxuu/[email protected]/img/qq/亲亲.gif
5760

layout/_partial/article.ejs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
%>
2121
<%- items.join(' ') %>
2222
<% } %>
23-
<% if (theme.services && theme.services.share == true && config.mob && config.mob.app_key && config.mob.list && (!page.meta || page.meta.share != false)) { %>
23+
<% if (theme.services && theme.services.share == true && (config.share || config.mob) && (!page.meta || page.meta.share != false)) { %>
2424
<%- partial('../_third-party/share') %>
2525
<% } %>
2626
</section>

layout/_third-party/share.ejs

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
1-
<% if (theme.services && theme.services.share == true && config.mob && config.mob.app_key && config.mob.list && page.layout == 'post' && page.share != false) { %>
1+
<% if (theme.services && theme.services.share == true && (config.share || config.mob) && page.layout == 'post' && page.share != false) { %>
22
<div class='metatag share -mob-share-list'>
33
<i class="left fas fa-share-alt fa-fw" aria-hidden="true"></i>
44
<div class="-mob-share-list share-body">
5-
<% (config.mob.list||[]).forEach(function(item){ %>
6-
<a class="-mob-share-<%- item.id %>" title="<%- item.name %>">
5+
<% ((config.share || config.mob.list)||[]).forEach(function(item){ %>
6+
<% if (item.id == 'qrcode' && theme.services.qrcode == true){ %>
7+
<a class='qrcode' rel="external nofollow noopener noreferrer" href='<%- qrcode(url) %>'>
78
<% if (item.img){ %>
89
<img src="<%- item.img %>">
910
<% } else if (item.icon){ %>
1011
<i class="<%- item.icon %> fa-fw"></i>
1112
<% } %>
12-
</a>
13+
</a>
14+
<% } else { %>
15+
<a class="-mob-share-<%- item.id %>" title="<%- item.name %>" rel="external nofollow noopener noreferrer"
16+
<% if (item.id == 'qzone'){ %>
17+
href="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=<%- post.permalink %>&title=<%- post.title + ' | ' + config.title %><%- (post.img || config.avatar) ? '&pics=' + (post.img || config.avatar) : '' %>&summary=<%- strip_html(post.excerpt) %>"
18+
<% } else if (item.id == 'qq'){ %>
19+
href="http://connect.qq.com/widget/shareqq/index.html?url=<%- post.permalink %>&title=<%- post.title + ' | ' + config.title %><%- (post.img || config.avatar) ? '&pics=' + (post.img || config.avatar) : '' %>&summary=<%- strip_html(post.excerpt) %>"
20+
<% } else if (item.id == 'weibo'){ %>
21+
href="http://service.weibo.com/share/share.php?url=<%- post.permalink %>&title=<%- post.title + ' | ' + config.title %><%- (post.img || config.avatar) ? '&pics=' + (post.img || config.avatar) : '' %>&summary=<%- strip_html(post.excerpt) %>"
22+
<% } %>
23+
>
24+
<% if (item.img){ %>
25+
<img src="<%- item.img %>">
26+
<% } else if (item.icon){ %>
27+
<i class="<%- item.icon %> fa-fw"></i>
28+
<% } %>
29+
</a>
30+
<% } %>
1331
<% }) %>
1432
</div>
1533
</div>

0 commit comments

Comments
 (0)