hexo-theme-stellar/layout/_partial/main/article/article_footer.ejs

147 lines
4.8 KiB
Plaintext

<%
function layoutDiv() {
var el = '';
var item = [];
if (page.references?.length > 0) {
item.push('references');
}
if (theme.article.license?.length > 0) {
item.push('license');
}
if (theme.article.share?.length > 0) {
item.push('share');
}
if (item.length === 0) {
return el;
}
el += '<div class="article-footer reveal fs14">';
if (page.references?.length > 0) {
function refList() {
var el = '';
for (let ref of page.references) {
el += `
<li class="post-title">
${markdown(ref)}
</li>
`
}
return el;
}
el += `
<section id="references">
<div class="header"><span>${__('meta.references')}</span></div>
<div class="body">
<ul>${refList()}</ul>
</div>
</section>
`
}
var license = ''
if (page.layout == 'post') {
if (theme.article.license && (page.license != false)) {
license = markdown(page.license || theme.article.license)
}
} else if (page.layout == 'wiki' && page.wiki) {
let proj = theme.wiki.tree[page.wiki]
if (page.license != null) {
license = markdown(page.license || theme.article.license)
} else if (proj?.license != null) {
if (proj.license == true) {
license = markdown(theme.article.license)
} else {
license = markdown(proj.license)
}
}
}
if (license.length > 0) {
el += `
<section id="license">
<div class="header"><span>${__('meta.license')}</span></div>
<div class="body">${license}</div>
</section>
`
}
var showSharePlugin = false
if (page.layout == 'post') {
showSharePlugin = page.share != false
} else if (page.layout == 'wiki' && page.wiki) {
let proj = theme.wiki.tree[page.wiki]
if (page.share != null) {
showSharePlugin = page.share == true
} else if (proj != null) {
showSharePlugin = proj.share == true
}
}
if (theme.article.share && showSharePlugin) {
function socialButtons() {
var el = ''
theme.article.share.forEach((item, i) => {
if (['wechat', 'weibo', 'email', 'link'].includes(item)) {
el += '<a class="social share-item ' + item + '"';
if (item == 'weibo') {
el += ' target="_blank" rel="external nofollow noopener noreferrer"';
}
if (item == 'wechat') {
el += ' onclick="util.toggle(&quot;qrcode-wechat&quot)"';
} else if (item == 'weibo') {
el += ' href="https://service.weibo.com/share/share.php?url=' + page.permalink;
el += '&title=' + (page.seo_title || (page.title + ' - ' + config.title));
if (page.layout == 'post' && page.cover) {
el += '&pics=' + page.cover;
} else if (page.layout == '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 + ' - ' + config.title) || page.seo_title) + '&amp;'
el += 'body=' + page.permalink + '"';
} else if (item == 'link') {
el += ' onclick="util.copy(&quot;copy-link&quot;, &quot;' + __('message.copied') + '&quot;)"';
}
el += '>';
if (item == 'wechat') {
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/social/b32ef3da1162a.svg"/>';
} else if (item == 'weibo') {
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/social/80c07e4dbb303.svg"/>';
} else if (item == 'email') {
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/social/a1b00e20f425d.svg"/>';
} else if (item == 'link') {
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.9/social/8411ed322ced6.svg"/>';
}
el += '</a>';
}
});
return el;
}
function qrcode() {
if (theme.article.share.includes('wechat')) {
return `
<div class="qrcode" id="qrcode-wechat" style="visibility:hidden;height:0">
<img src="https://api.qrserver.com/v1/create-qr-code/?size=256x256&data=${page.permalink}"/>
</div>
`
} else {
return ''
}
}
el += `
<section id="share">
<div class="header"><span>${__('meta.share')}</span></div>
<div class="body">
<div class="link"><input class="copy-area" readonly="true" id="copy-link" value="${page.permalink}" /></div>
<div class="social-wrap dis-select">${socialButtons()}</div>
${qrcode()}
</div>
</section>
`
}
el += '</div>';
return el;
}
%>
<%- layoutDiv(); %>