Skip to content

Commit 55e5ecd

Browse files
committed
rewrite share & v1.2
1 parent 5018c9c commit 55e5ecd

File tree

16 files changed

+171
-156
lines changed

16 files changed

+171
-156
lines changed

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# hexo-theme-indigo
22
# https://github.com/yscoder/hexo-theme-indigo
3-
version: 1.1.12
3+
version: 1.2
44

55
#添加新菜单项遵循以下规则
66
# menu:

layout/_partial/after-footer.ejs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
<div class="mask" id="mask"></div>
22
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>
3+
<script>
4+
var BLOG = { ROOT: '<%= config.root %>', SHARE: <%- theme.share %>, REWARD: <%- Boolean(page.reward) %> }</script>
35
<% if(theme.share){ %>
4-
<script>var BLOG = { ROOT: '<%= config.root %>' };
5-
BLOG.SHARE = {
6-
title: "<%-(page.title || config.title) %>",
7-
summary: document.getElementsByName('summary')[0].content,
8-
url: "<%=url.replace(/index\.html$/, '') %>" }
9-
</script>
10-
<%- partial('post/share', {className: 'global-share'}) %>
6+
<%- partial('post/share', {scope: 'global'}) %>
117
<% } %>

layout/_partial/head.ejs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
<% if (theme.rss){ %>
4545
<link rel="alternative" href="<%- theme.rss %>" title="<%= config.title %>" type="application/atom+xml">
4646
<% } %>
47-
<meta name="summary" content="<%= strip_html(page.excerpt || config.description) %>">
4847
<%- favicon_tag(theme.favicon) %>
4948
<link rel="stylesheet" href="<%= url_for('/css/style.css?v='+ theme.version) %>">
5049
</head>

layout/_partial/header.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</div>
1717
<% }%>
1818
<% if(theme.share){ %>
19-
<a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-share">
19+
<a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
2020
<i class="icon icon-lg icon-share-alt"></i>
2121
</a>
2222
<% } %>
@@ -29,7 +29,7 @@
2929
<h5 class="subtitle">
3030
<% if(is_post()){ %>
3131
<%- partial('post/head-meta') %>
32-
<% } else if(is_home()){ %>
32+
<% } else if(is_home()){ %>
3333
<%- config.subtitle %>
3434
<% } else if (page.layout === 'page' && page.description) {%>
3535
<%- page.description %>

layout/_partial/post/reward-btn.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<% if(page.reward){ %>
2-
<div class="post-reward">
3-
<a id="rewardBtn" href="javascript:;" class="post-reward-btn waves-effect waves-circle waves-light"></a>
2+
<div class="page-reward">
3+
<a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light"></a>
44
</div>
5-
<% } %>
5+
<% } %>

layout/_partial/post/reward.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<% if(page.reward){ %>
2-
<div id="reward" class="reward-lay">
3-
<a class="reward-off" id="rewardOff" href="javascript:;"><i class="icon icon-close"></i></a>
2+
<div id="reward" class="page-modal reward-lay">
3+
<a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
44
<h3 class="reward-title">
55
<i class="icon icon-quote-left"></i>
66
<%=theme.reward.title %>
@@ -22,4 +22,4 @@
2222
<% } %>
2323
</ul>
2424
</div>
25-
<% } %>
25+
<% } %>

layout/_partial/post/share-fab.ejs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<% if(theme.share){ %>
2-
<div class="post-share-wrap">
3-
<%- partial('share', {
4-
className: 'post-share'
5-
}) %>
6-
<a href="javascript:;" id="share-fab" class="post-share-fab waves-effect waves-circle">
2+
<div class="page-share-wrap">
3+
<%- partial('share', { scope: 'page' }) %>
4+
<a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
75
<i class="icon icon-share-alt icon-lg"></i>
86
</a>
97
</div>

layout/_partial/post/share.ejs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,52 @@
1-
<div class="<%=className %>" id="<%=className %>">
1+
<%
2+
// 使用 sns 直接分享接口
3+
// 微信使用 http://s.jiathis.com/qrcode.php?url=xxx
4+
var sUrl = url.replace(/index\.html$/, '')
5+
var sTitle = page.title ? ''+ page.title +'》 — ' + config.title : config.title
6+
var sDesc = truncate(strip_html(page.excerpt || config.description), { length: 80})
7+
var sPic = page.photos && page.photos.length ? page.photos[0] : url_for(config.avatar)
8+
%>
9+
10+
<div class="<%- scope %>-share" id="<%- scope %>Share">
211
<div class="tit">分享到:</div>
312
<ul class="reset share-icons">
413
<li>
5-
<a class="weibo share-sns" href="javascript:;" data-title="微博" data-service="tsina">
14+
<a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=<%-sUrl%>&title=<%-sTitle%>&pic=<%-sPic%>" data-title="微博">
615
<i class="icon icon-weibo"></i>
716
</a>
817
</li>
918
<li>
10-
<a class="weixin share-sns" href="javascript:;" data-title="微信" data-service="weixin">
19+
<a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
1120
<i class="icon icon-weixin"></i>
1221
</a>
1322
</li>
1423
<li>
15-
<a class="qq share-sns" href="javascript:;" data-title=" QQ" data-service="cqq">
24+
<a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=<%-sUrl%>&title=<%-sTitle%>&source=<%-sDesc%>" data-title=" QQ">
1625
<i class="icon icon-qq"></i>
1726
</a>
1827
</li>
1928
<li>
20-
<a class="facebook share-sns" href="javascript:;" data-title=" Facebook" data-service="fb">
29+
<a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<%-sUrl%>" data-title=" Facebook">
2130
<i class="icon icon-facebook"></i>
2231
</a>
2332
</li>
2433
<li>
25-
<a class="twitter share-sns" href="javascript:;" data-title=" Twitter" data-service="twitter">
34+
<a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=<%-sTitle%>&url=<%-sUrl%>&via=<%-config.url%>" data-title=" Twitter">
2635
<i class="icon icon-twitter"></i>
2736
</a>
2837
</li>
2938
<li>
30-
<a class="douban share-sns" href="javascript:;" data-title="豆瓣" data-service="douban">
31-
39+
<a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=<%-sUrl%>" data-title=" Google+">
40+
<i class="icon icon-google-plus"></i>
3241
</a>
3342
</li>
3443
</ul>
3544
</div>
45+
46+
<% if(scope === 'global') { %>
47+
<div class="page-modal wx-share" id="wxShare">
48+
<a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
49+
<p>扫一扫,分享到微信</p>
50+
<img src="http://s.jiathis.com/qrcode.php?url=<%-sUrl%>" alt="微信分享二维码"/>
51+
</div>
52+
<% } %>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "hexo-theme-material-indigo",
3-
"version": "1.1.12",
3+
"version": "1.2.0",
44
"private": true
55
}

source/css/_partial/layout.less

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@
177177
&.in {
178178
visibility: visible;
179179
pointer-events: auto;
180-
opacity: .5;
181-
filter: alpha(opacity=50);
180+
opacity: .3;
182181
}
183182
}
184183

source/css/_partial/page.less

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
.page-content {
2424
margin-bottom: 30px;
2525
border-bottom: 2px solid @borderColor;
26-
26+
2727
> blockquote,
2828
> pre,
2929
img,
@@ -131,7 +131,7 @@
131131
text-align: center;
132132
.card(3px)
133133
}
134-
134+
135135
> h6 {
136136
position: absolute;
137137
top: 50%;
@@ -175,13 +175,13 @@
175175
.page-about-me {
176176
position: relative;
177177
padding: 30px 35px!important;
178-
178+
179179
.avatar {
180180
margin-right: 35px;
181181
width: 100px;
182182
height: 100px;
183183
box-shadow: @boxShadow;
184-
184+
185185
img {
186186
border-radius: 50%;
187187
}
@@ -204,10 +204,51 @@
204204
}
205205
.page-about-me {
206206
padding: 15px 20px!important;
207-
.avatar {
207+
.avatar {
208208
margin-right: 20px;
209209
width: 60px;
210210
height: 60px;
211211
}
212212
}
213-
}
213+
}
214+
215+
.page-modal {
216+
display: none;
217+
position: fixed;
218+
top: 24%;
219+
left: 50%;
220+
z-index: 120;
221+
padding: 30px;
222+
text-align: center;
223+
color: @secondaryTextColor;
224+
background: #fff;
225+
border-radius: 4px;
226+
box-shadow: @boxShadow;
227+
opacity: 0;
228+
.transform(translate(-50%, -200%));
229+
230+
&.ready {
231+
visibility: hidden;
232+
display: block;
233+
.transform(translate(-50%, -100%));
234+
.transition(.3s);
235+
}
236+
237+
&.in {
238+
visibility: visible;
239+
opacity: 1;
240+
.transform(translate(-50%, 0));
241+
}
242+
243+
.close {
244+
position: absolute;
245+
right: 15px;
246+
top: 15px;
247+
color: rgba(0, 0, 0, .2);
248+
font-size: 16px;
249+
line-height: 20px;
250+
&:hover, &:active {
251+
color: rgba(0, 0, 0, .4);
252+
}
253+
}
254+
}

source/css/_partial/reward.less

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
.post-reward {
2+
.page-reward {
33
margin: 60px 0;
44
text-align: center;
55
}
6-
.post-reward-btn {
6+
.page-reward-btn {
77
width: 56px;
88
height: 56px;
99
line-height: 56px;
@@ -17,44 +17,6 @@
1717
}
1818
}
1919

20-
.reward-lay {
21-
display: none;
22-
position: fixed;
23-
top: 24%;
24-
left: 50%;
25-
z-index: 120;
26-
padding: 30px;
27-
text-align: center;
28-
color: @secondaryTextColor;
29-
background: #fff;
30-
border-radius: 4px;
31-
box-shadow: @boxShadow;
32-
opacity: 0;
33-
.transform(translate(-50%, -200%));
34-
35-
&.ready {
36-
visibility: hidden;
37-
display: block;
38-
.transform(translate(-50%, -100%));
39-
.transition(.4s);
40-
}
41-
&.in {
42-
visibility: visible;
43-
opacity: 1;
44-
.transform(translate(-50%, 0));
45-
}
46-
}
47-
.reward-off {
48-
position: absolute;
49-
right: 15px;
50-
top: 15px;
51-
color: rgba(0, 0, 0, .2);
52-
font-size: 16px;
53-
line-height: 20px;
54-
&:hover, &:active {
55-
color: rgba(0, 0, 0, .4);
56-
}
57-
}
5820
.reward-title {
5921
position: relative;
6022
padding: 10px 30px;
@@ -105,10 +67,10 @@
10567

10668
}
10769

108-
@media screen and (max-width: 360px) {
70+
@media screen and (max-width: 360px) {
10971
.reward-items {
11072
li {
11173
width: 130px;
11274
}
11375
}
114-
}
76+
}

source/css/_partial/share.less

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
background: #55ACEE
3636
}
3737

38-
&.douban {
39-
background: #228A31
38+
&.google {
39+
background: #db4437
4040
}
4141

4242
}
@@ -102,7 +102,7 @@
102102
@share-fab-size: 42px;
103103
@share-icon-size: @share-fab-size - 8px;
104104

105-
.post-share-fab {
105+
.page-share-fab {
106106
display: block;
107107
width: @share-fab-size;
108108
height: @share-fab-size;
@@ -112,17 +112,17 @@
112112
.boxShadow();
113113
}
114114

115-
.post-share-wrap {
115+
.page-share-wrap {
116116
position: absolute;
117117
right: 35px;
118118
top: @share-fab-size / -2;
119119
z-index: 2;
120-
.post-share {
120+
.page-share {
121121
visibility: hidden
122122
}
123123
}
124124

125-
.post-share {
125+
.page-share {
126126
position: absolute;
127127
bottom: @share-fab-size + 6px;
128128
right: 4px;
@@ -151,7 +151,7 @@
151151
font-size: 1.33333em;
152152
border-radius: 50%;
153153
.tip-left();
154-
.boxShadow();
154+
.boxShadow(.3s);
155155
opacity: 0;
156156
.transform(scale(0));
157157
-webkit-transform-origin: center bottom;
@@ -169,3 +169,13 @@
169169

170170
}
171171
}
172+
173+
.wx-share {
174+
p {
175+
margin: 0 0 15px;
176+
}
177+
178+
img {
179+
width: 200px;
180+
}
181+
}

source/css/_partial/variable.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
}
147147

148148
&:after {
149-
left: -4px;
149+
left: -3px;
150150
border-left-color: rgba(0, 0, 0, .8);
151151
}
152152
}

0 commit comments

Comments
 (0)