This commit is contained in:
xaoxuu 2021-02-25 13:12:04 +08:00
parent 6d983239ed
commit a2943d55b8
12 changed files with 124 additions and 62 deletions

View File

@ -57,7 +57,7 @@ article:
# 文章许可协议
license: '本文采用 [署名-非商业性使用-相同方式共享 4.0 国际](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh) 许可协议,转载请注明出处。'
# 分享
share: [wechat, weibo, email, link]
share: # [weibo, email, link] # wechat 需要安装二维码插件: npm i hexo-helper-qrcode
# 相关文章,需要安装插件 (for layout: post)
# npm i hexo-related-popular-posts
related_posts:

View File

@ -1,5 +1,8 @@
<%
function layoutDiv() {
if (page.layout == 'wiki' && !page.references) {
return '';
}
let el = '';
el += '<div class="references-wrap">';
if (page.references && page.references.length > 0) {
@ -19,53 +22,72 @@ function layoutDiv() {
el += '</section>';
}
if (theme.article.license && page.license != false) {
el += '<section id="license">';
el += '<div class="header">';
el += '<span>' + __('meta.license') + '</span>';
el += '</div>';
el += '<div class="body">';
el += markdown(page.license || theme.article.license);
el += '</div>';
el += '</section>';
}
if (page.layout == 'post') {
if (theme.article.license && page.license != false) {
el += '<section id="license">';
el += '<div class="header">';
el += '<span>' + __('meta.license') + '</span>';
el += '</div>';
el += '<div class="body">';
el += markdown(page.license || theme.article.license);
el += '</div>';
el += '</section>';
}
if (theme.article.share && page.share != false) {
el += '<section id="share">';
el += '<div class="header">';
el += '<span>' + __('meta.share') + '</span>';
el += '</div>';
el += '<div class="body social-wrap">';
theme.article.share.forEach((item, i) => {
if (['wechat', 'weibo', 'email', 'link'].includes(item)) {
el += '<a class="social share-item ' + item + '"';
if (item == 'wechat') {
el += ' href="#"';
} else if (item == 'weibo') {
el += ' href="#"';
} else if (item == 'email') {
el += ' href="#"';
} else if (item == 'link') {
el += ' href="#"';
if (theme.article.share && page.share != false) {
el += '<section id="share">';
el += '<div class="header">';
el += '<span>' + __('meta.share') + '</span>';
el += '</div>';
el += '<div class="body">';
el += '<div class="link"><input class="copy-area" readonly="true" id="copy-link" value="' + page.permalink + '" /></div>';
el += '<div class="social-wrap">';
theme.article.share.forEach((item, i) => {
if (['wechat', 'weibo', 'email', 'link'].includes(item)) {
el += '<a class="social share-item ' + item + '"';
if (item == 'wechat') {
el += ' onclick=\'util.toggle_qrcode()\'';
} else if (item == 'weibo') {
el += ' href="http://service.weibo.com/share/share.php?url=' + page.permalink;
el += '&title=' + (page.seo_title || page.title) + ' - ' + config.title;
if (page.latyout == 'post' && page.cover) {
el += '&pics=' + page.cover;
} else if (page.latyout == 'wiki' && page.logo && page.logo.src) {
el += '&pics=' + page.logo.src;
}
el += '&summary=' + truncate(page.description || strip_html(page.excerpt || page.content), {length: 120});
el += '"';
} else if (item == 'email') {
el += ' href="mailto:?subject=' + (page.title || page.seo_title) + ' - ' + config.title + '&amp;'
el += 'body=' + page.permalink + '"';
} else if (item == 'link') {
el += ' onclick=\'util.copy_link()\'';
}
el += '>';
if (item == 'wechat') {
el += '<img src="https://7.dusays.com/2021/02/24/b32ef3da1162a.svg"/>';
} else if (item == 'weibo') {
el += '<img src="https://7.dusays.com/2021/02/24/80c07e4dbb303.svg"/>';
} else if (item == 'email') {
el += '<img src="https://7.dusays.com/2021/02/24/a1b00e20f425d.svg"/>';
} else if (item == 'link') {
el += '<img src="https://7.dusays.com/2021/02/24/8411ed322ced6.svg"/>';
}
el += '</a>';
}
el += '>';
if (item == 'wechat') {
el += '<img src="https://7.dusays.com/2021/02/24/b32ef3da1162a.svg"/>';
} else if (item == 'weibo') {
el += '<img src="https://7.dusays.com/2021/02/24/80c07e4dbb303.svg"/>';
} else if (item == 'email') {
el += '<img src="https://7.dusays.com/2021/02/24/a1b00e20f425d.svg"/>';
} else if (item == 'link') {
el += '<img src="https://7.dusays.com/2021/02/24/8411ed322ced6.svg"/>';
}
el += '</a>';
});
el += '</div>';
if (theme.article.share.includes('wechat')) {
el += '<div class="qrcode" id="qrcode-wechat" style="display:none">';
const src = qrcode(url,{margin:1,size:8});
el += '<img src="' + src + '"/>';
el += '</div>';
}
});
el += '</div>';
el += '</section>';
el += '</div>';
el += '</section>';
}
}
el += '</div>';
return el;
}

View File

@ -36,8 +36,8 @@
<div id='breadcrumb'<%- category_color(catPage.title) %>>
<a class='cap breadcrumb' href='/'><%- __('btn.home') %></a>
<span class="sep"></span>
<% if (page.menu_id && theme.sidebar.menu[page.menu_id] && theme.sidebar.menu[page.menu_id].url) { %>
<a class='cap breadcrumb' href='<%- url_for(theme.sidebar.menu[page.menu_id].url) %>'><%- __(theme.sidebar.menu[page.menu_id].title) %></a>
<% if (page.menu_id && theme.sidebar.menu[page.menu_id] && md_link(theme.sidebar.menu[page.menu_id])) { %>
<a class='cap breadcrumb' href='<%- url_for(md_link(theme.sidebar.menu[page.menu_id])) %>'><%- __(md_text(theme.sidebar.menu[page.menu_id])) %></a>
<% } else { %>
<a class='cap breadcrumb' href='<%- url_for(config.wiki_dir || "/wiki/") %>'><%- __('btn.wiki') %></a>
<% } %>

View File

@ -109,6 +109,7 @@ ol ul, ol ol
table:not([class])
border-collapse: collapse
overflow: auto
display: block
margin: 1rem 0
max-width: 100%
vertical-align: text-top
@ -125,3 +126,13 @@ table:not([class])
trans()
&:hover
background: var(--block)
input
display: block
a[onclick]:hover
cursor: pointer
input
background: none
border: none

View File

@ -4,8 +4,9 @@
margin-top: 1.75rem
top: -2px
background: var(--site-bg)
padding: 0.5rem 1.25rem 0.38rem
padding: 0.5rem 1rem 0.38rem
z-index: 1
nav.cap
display: flex
overflow: scroll
@ -14,17 +15,15 @@ nav.cap
margin: 0
a
padding: 0.5rem 0.75rem
margin-left: 0.25rem
color: var(--text-p3)
border-radius: 4px
font-weight: 600
white-space: nowrap
trans1 background
&.active,&:hover
&.active, &:hover
background: var(--hover-block)
color: var(--text-p1)
a+a
margin-left: 4px
//
.breadcrumb-navigation

View File

@ -16,3 +16,5 @@
color: var(--text-p1)
font-size: 2rem
font-weight: 400
@media screen and (max-width: $device-mobile)
font-size: 1.5rem

View File

@ -3,12 +3,18 @@
padding: 1rem
background: var(--block)
border-radius: $border-block
border: 1px solid var(--block-border)
.header
font-weight: 500
color: var(--text-p3)
margin-bottom: 0.75rem
font-size: 1.25rem
.body
input.copy-area
margin-bottom: 0.5rem
width: 100%
font-family: $ff-code
font-size: $fs12
p
font-size: $fs14
color: var(--text-p2)
@ -22,12 +28,23 @@
.post-title
margin: 0.5rem 0
line-height: 1.2
font-size: $fs13
font-size: $fs14
section+section
margin-top: 2rem
margin-top: 1rem
padding-top: 1rem
border-top: 1px solid var(--block-border)
.references-wrap .social-wrap
grid-gap: $gap * 0.25 $gap * 0.5
grid-template-columns: repeat(auto-fill, 40px)
a.social
padding: 8px
.references-wrap .qrcode
margin: 2rem auto 1rem
width: 128px
img
object-fit: contain
.references-wrap .qrcode.display
display: block !important

View File

@ -11,11 +11,12 @@ div.related-posts-wrap
align-items: flex-start
scrollbar(8px, 4px)
padding-bottom: 8px
border-radius: $border-block
a
flex-grow: 0
flex-shrink: 0
background: var(--card)
border-radius: 0.5rem
border-radius: $border-block
padding-bottom: 1rem
line-height: 1.2
display: flex

View File

@ -123,9 +123,10 @@ nav.menu
margin-top: 0
margin-bottom: 1rem
line-height: 0
.social-wrap
disable-select()
display: grid
grid-gap: $gap * 0.25 $gap * 0.25
grid-template-columns: repeat(auto-fill, 32px)

View File

@ -2,8 +2,3 @@
line-height: 0
a.ghcard
display: inline-block
img
border-radius: 5px
transition: box-shadow
&:hover img
box-shadow: $boxshadow-float, $boxshadow-card-float

View File

@ -29,15 +29,15 @@ div.timenode
position: relative
background: var(--card)
border: 1px solid var(--block-border)
border-radius: 6px
border-radius: $border-block
margin-top: 1rem
margin-bottom: 1rem
font-size: $fs14
.header
line-height: 1.2
background: var(--block)
border-top-left-radius: 5px
border-top-right-radius: 5px
border-top-left-radius: "calc(%s - 1px)" % $border-block
border-top-right-radius: "calc(%s - 1px)" % $border-block
border-bottom: 1px solid var(--block-border)
display: flex
justify-content: space-between

View File

@ -127,6 +127,20 @@ const util = {
}
},
copy_link: () => {
const el = document.getElementById("copy-link");
if (el) {
el.select();
document.execCommand("Copy");
}
},
toggle_qrcode: () => {
const el = document.getElementById("qrcode-wechat");
if (el) {
el.classList.toggle("display");
}
},
}