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) 许可协议,转载请注明出处。' 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) # 相关文章,需要安装插件 (for layout: post)
# npm i hexo-related-popular-posts # npm i hexo-related-popular-posts
related_posts: related_posts:

View File

@ -1,5 +1,8 @@
<% <%
function layoutDiv() { function layoutDiv() {
if (page.layout == 'wiki' && !page.references) {
return '';
}
let el = ''; let el = '';
el += '<div class="references-wrap">'; el += '<div class="references-wrap">';
if (page.references && page.references.length > 0) { if (page.references && page.references.length > 0) {
@ -19,6 +22,7 @@ function layoutDiv() {
el += '</section>'; el += '</section>';
} }
if (page.layout == 'post') {
if (theme.article.license && page.license != false) { if (theme.article.license && page.license != false) {
el += '<section id="license">'; el += '<section id="license">';
el += '<div class="header">'; el += '<div class="header">';
@ -35,18 +39,29 @@ function layoutDiv() {
el += '<div class="header">'; el += '<div class="header">';
el += '<span>' + __('meta.share') + '</span>'; el += '<span>' + __('meta.share') + '</span>';
el += '</div>'; el += '</div>';
el += '<div class="body social-wrap">'; 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) => { theme.article.share.forEach((item, i) => {
if (['wechat', 'weibo', 'email', 'link'].includes(item)) { if (['wechat', 'weibo', 'email', 'link'].includes(item)) {
el += '<a class="social share-item ' + item + '"'; el += '<a class="social share-item ' + item + '"';
if (item == 'wechat') { if (item == 'wechat') {
el += ' href="#"'; el += ' onclick=\'util.toggle_qrcode()\'';
} else if (item == 'weibo') { } else if (item == 'weibo') {
el += ' href="#"'; 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') { } else if (item == 'email') {
el += ' href="#"'; el += ' href="mailto:?subject=' + (page.title || page.seo_title) + ' - ' + config.title + '&amp;'
el += 'body=' + page.permalink + '"';
} else if (item == 'link') { } else if (item == 'link') {
el += ' href="#"'; el += ' onclick=\'util.copy_link()\'';
} }
el += '>'; el += '>';
if (item == 'wechat') { if (item == 'wechat') {
@ -62,9 +77,16 @@ function layoutDiv() {
} }
}); });
el += '</div>'; 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 += '</section>';
} }
}
el += '</div>'; el += '</div>';
return el; return el;

View File

@ -36,8 +36,8 @@
<div id='breadcrumb'<%- category_color(catPage.title) %>> <div id='breadcrumb'<%- category_color(catPage.title) %>>
<a class='cap breadcrumb' href='/'><%- __('btn.home') %></a> <a class='cap breadcrumb' href='/'><%- __('btn.home') %></a>
<span class="sep"></span> <span class="sep"></span>
<% if (page.menu_id && theme.sidebar.menu[page.menu_id] && theme.sidebar.menu[page.menu_id].url) { %> <% 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(theme.sidebar.menu[page.menu_id].url) %>'><%- __(theme.sidebar.menu[page.menu_id].title) %></a> <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 { %> <% } else { %>
<a class='cap breadcrumb' href='<%- url_for(config.wiki_dir || "/wiki/") %>'><%- __('btn.wiki') %></a> <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]) table:not([class])
border-collapse: collapse border-collapse: collapse
overflow: auto overflow: auto
display: block
margin: 1rem 0 margin: 1rem 0
max-width: 100% max-width: 100%
vertical-align: text-top vertical-align: text-top
@ -125,3 +126,13 @@ table:not([class])
trans() trans()
&:hover &:hover
background: var(--block) 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 margin-top: 1.75rem
top: -2px top: -2px
background: var(--site-bg) background: var(--site-bg)
padding: 0.5rem 1.25rem 0.38rem padding: 0.5rem 1rem 0.38rem
z-index: 1 z-index: 1
nav.cap nav.cap
display: flex display: flex
overflow: scroll overflow: scroll
@ -14,6 +15,7 @@ nav.cap
margin: 0 margin: 0
a a
padding: 0.5rem 0.75rem padding: 0.5rem 0.75rem
margin-left: 0.25rem
color: var(--text-p3) color: var(--text-p3)
border-radius: 4px border-radius: 4px
font-weight: 600 font-weight: 600
@ -22,9 +24,6 @@ nav.cap
&.active, &:hover &.active, &:hover
background: var(--hover-block) background: var(--hover-block)
color: var(--text-p1) color: var(--text-p1)
a+a
margin-left: 4px
// //
.breadcrumb-navigation .breadcrumb-navigation

View File

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

View File

@ -3,12 +3,18 @@
padding: 1rem padding: 1rem
background: var(--block) background: var(--block)
border-radius: $border-block border-radius: $border-block
border: 1px solid var(--block-border)
.header .header
font-weight: 500 font-weight: 500
color: var(--text-p3) color: var(--text-p3)
margin-bottom: 0.75rem margin-bottom: 0.75rem
font-size: 1.25rem font-size: 1.25rem
.body .body
input.copy-area
margin-bottom: 0.5rem
width: 100%
font-family: $ff-code
font-size: $fs12
p p
font-size: $fs14 font-size: $fs14
color: var(--text-p2) color: var(--text-p2)
@ -22,12 +28,23 @@
.post-title .post-title
margin: 0.5rem 0 margin: 0.5rem 0
line-height: 1.2 line-height: 1.2
font-size: $fs13 font-size: $fs14
section+section section+section
margin-top: 2rem margin-top: 1rem
padding-top: 1rem
border-top: 1px solid var(--block-border)
.references-wrap .social-wrap .references-wrap .social-wrap
grid-gap: $gap * 0.25 $gap * 0.5 grid-gap: $gap * 0.25 $gap * 0.5
grid-template-columns: repeat(auto-fill, 40px) grid-template-columns: repeat(auto-fill, 40px)
a.social a.social
padding: 8px 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 align-items: flex-start
scrollbar(8px, 4px) scrollbar(8px, 4px)
padding-bottom: 8px padding-bottom: 8px
border-radius: $border-block
a a
flex-grow: 0 flex-grow: 0
flex-shrink: 0 flex-shrink: 0
background: var(--card) background: var(--card)
border-radius: 0.5rem border-radius: $border-block
padding-bottom: 1rem padding-bottom: 1rem
line-height: 1.2 line-height: 1.2
display: flex display: flex

View File

@ -126,6 +126,7 @@ nav.menu
.social-wrap .social-wrap
disable-select()
display: grid display: grid
grid-gap: $gap * 0.25 $gap * 0.25 grid-gap: $gap * 0.25 $gap * 0.25
grid-template-columns: repeat(auto-fill, 32px) grid-template-columns: repeat(auto-fill, 32px)

View File

@ -2,8 +2,3 @@
line-height: 0 line-height: 0
a.ghcard a.ghcard
display: inline-block 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 position: relative
background: var(--card) background: var(--card)
border: 1px solid var(--block-border) border: 1px solid var(--block-border)
border-radius: 6px border-radius: $border-block
margin-top: 1rem margin-top: 1rem
margin-bottom: 1rem margin-bottom: 1rem
font-size: $fs14 font-size: $fs14
.header .header
line-height: 1.2 line-height: 1.2
background: var(--block) background: var(--block)
border-top-left-radius: 5px border-top-left-radius: "calc(%s - 1px)" % $border-block
border-top-right-radius: 5px border-top-right-radius: "calc(%s - 1px)" % $border-block
border-bottom: 1px solid var(--block-border) border-bottom: 1px solid var(--block-border)
display: flex display: flex
justify-content: space-between 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");
}
},
} }