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

150 lines
4.4 KiB
Plaintext
Raw Normal View History

2021-02-19 23:33:19 +08:00
<%
function layoutDiv() {
2021-07-14 13:21:58 +08:00
var el = '';
var item = [];
2023-12-06 13:22:50 +08:00
if (page.references?.length > 0) {
2021-07-14 13:21:58 +08:00
item.push('references');
}
2023-12-06 13:22:50 +08:00
if (theme.article.license?.length > 0) {
item.push('license');
}
if (theme.article.share?.length > 0) {
item.push('share');
2021-07-14 13:21:58 +08:00
}
if (item.length === 0) {
return el;
2021-02-25 13:12:04 +08:00
}
2024-01-19 01:05:44 +08:00
el += `<div class="article-footer${scrollreveal(' ')} fs14">`
2023-12-06 13:22:50 +08:00
if (page.references?.length > 0) {
function refList() {
var el = '';
2023-12-20 15:01:46 +08:00
for (let ref of page.references) {
el += `
<li class="post-title">
${markdown(ref)}
</li>
`
}
2023-12-06 13:22:50 +08:00
return el;
}
el += `
<section id="references">
<div class="header"><span>${__('meta.references')}</span></div>
<div class="body">
<ul>${refList()}</ul>
</div>
</section>
`
2021-02-19 23:33:19 +08:00
}
2021-02-25 00:05:23 +08:00
2023-12-06 13:22:50 +08:00
var license = ''
2024-01-13 21:10:26 +08:00
if (page.wiki) {
2024-01-19 01:05:44 +08:00
const proj = theme.wiki.tree[page.wiki]
2023-12-06 13:22:50 +08:00
if (page.license != null) {
2024-01-08 12:38:50 +08:00
license = page.license || theme.article.license
2023-12-06 13:22:50 +08:00
} else if (proj?.license != null) {
2023-12-06 21:54:42 +08:00
if (proj.license == true) {
2024-01-08 12:38:50 +08:00
license = theme.article.license
2023-12-06 21:54:42 +08:00
} else {
2024-01-08 12:38:50 +08:00
license = proj.license
2023-12-06 21:54:42 +08:00
}
2023-12-06 13:22:50 +08:00
}
2024-01-13 21:10:26 +08:00
} else if (page.layout == 'post') {
if (theme.article.license && (page.license != false)) {
license = page.license || theme.article.license
}
2023-12-06 13:22:50 +08:00
}
if (license.length > 0) {
2024-01-08 12:38:50 +08:00
var author = null
if (theme.authors) {
if (page.author?.length > 0 && theme.authors[page.author] != null) {
author = theme.authors[page.author]
} else {
author = theme.default_author
}
}
if (author) {
2024-02-18 13:03:28 +08:00
license = license.replace('{author.name}', author.name).replace('{author.url}', author.url)
2024-01-08 12:38:50 +08:00
}
2023-12-06 13:22:50 +08:00
el += `
<section id="license">
<div class="header"><span>${__('meta.license')}</span></div>
2024-01-08 12:38:50 +08:00
<div class="body">${markdown(license)}</div>
2023-12-06 13:22:50 +08:00
</section>
`
}
2021-02-25 00:05:23 +08:00
2023-12-06 13:22:50 +08:00
var showSharePlugin = false
2024-01-13 21:10:26 +08:00
if (page.wiki) {
2024-01-19 01:05:44 +08:00
const proj = theme.wiki.tree[page.wiki]
2023-12-06 13:22:50 +08:00
if (page.share != null) {
showSharePlugin = page.share == true
} else if (proj != null) {
showSharePlugin = proj.share == true
}
2024-01-13 21:10:26 +08:00
} else if (page.layout == 'post') {
showSharePlugin = page.share != false
2023-12-06 13:22:50 +08:00
}
if (theme.article.share && showSharePlugin) {
function socialButtons() {
var el = ''
2021-02-25 13:12:04 +08:00
theme.article.share.forEach((item, i) => {
if (['wechat', 'weibo', 'email', 'link'].includes(item)) {
2021-02-27 20:08:36 +08:00
el += '<a class="social share-item ' + item + '"';
if (item == 'weibo') {
el += ' target="_blank" rel="external nofollow noopener noreferrer"';
}
2021-02-25 13:12:04 +08:00
if (item == 'wechat') {
2021-02-27 20:08:36 +08:00
el += ' onclick="util.toggle(&quot;qrcode-wechat&quot)"';
2021-02-25 13:12:04 +08:00
} else if (item == 'weibo') {
2021-02-26 20:02:32 +08:00
el += ' href="https://service.weibo.com/share/share.php?url=' + page.permalink;
2024-01-18 12:33:12 +08:00
el += '&title=' + page.title + ' - ' + config.title;
if (page.layout == 'post' && page.cover) {
2021-02-25 13:12:04 +08:00
el += '&pics=' + page.cover;
2024-01-19 01:05:44 +08:00
} else if (page.wiki && page.icon) {
2024-01-13 21:10:26 +08:00
el += '&pics=' + page.icon;
2021-02-25 13:12:04 +08:00
}
el += '&summary=' + truncate(page.description || strip_html(page.excerpt || page.content), {length: 120});
el += '"';
} else if (item == 'email') {
2024-01-18 12:33:12 +08:00
el += ' href="mailto:?subject=' + page.title + ' - ' + config.title + '&amp;'
2021-02-25 13:12:04 +08:00
el += 'body=' + page.permalink + '"';
} else if (item == 'link') {
2021-02-27 20:08:36 +08:00
el += ' onclick="util.copy(&quot;copy-link&quot;, &quot;' + __('message.copied') + '&quot;)"';
2021-02-25 13:12:04 +08:00
}
el += '>';
2024-01-19 13:51:55 +08:00
el += icon(`share:${item}`)
2021-02-25 13:12:04 +08:00
el += '</a>';
2021-02-25 00:05:23 +08:00
}
2021-02-25 13:12:04 +08:00
});
2023-12-06 13:22:50 +08:00
return el;
}
function qrcode() {
2021-02-25 13:12:04 +08:00
if (theme.article.share.includes('wechat')) {
2023-12-06 13:22:50 +08:00
return `
2024-01-31 22:45:07 +08:00
<div class="qrcode" id="qrcode-wechat" style="opacity:0;height:0">
2023-12-06 13:22:50 +08:00
<img src="https://api.qrserver.com/v1/create-qr-code/?size=256x256&data=${page.permalink}"/>
</div>
`
} else {
return ''
2021-02-25 00:05:23 +08:00
}
2021-02-25 13:12:04 +08:00
}
2023-12-06 13:22:50 +08:00
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>
`
2021-02-25 00:05:23 +08:00
}
el += '</div>';
return el;
2021-02-19 23:33:19 +08:00
}
%>
<%- layoutDiv(); %>