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

115 lines
4.3 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 = [];
if (page.references && page.references.length > 0) {
item.push('references');
}
if (page.layout !== 'wiki') {
if (theme.article.license && theme.article.license.length > 0) {
item.push('license');
}
if (theme.article.share && theme.article.share.length > 0) {
item.push('share');
}
}
if (item.length === 0) {
return el;
2021-02-25 13:12:04 +08:00
}
2021-07-13 22:25:24 +08:00
el += '<div class="article-footer reveal fs14">';
2021-02-19 23:33:19 +08:00
if (page.references && page.references.length > 0) {
2021-02-25 00:05:23 +08:00
el += '<section id="references">';
el += '<div class="header">';
el += '<span>' + __('meta.references') + '</span>';
el += '</div>';
el += '<div class="body"><ul>';
2021-02-19 23:33:19 +08:00
page.references.forEach((item, i) => {
2021-02-25 00:05:23 +08:00
el += '<li class="post-title">';
2021-02-27 20:08:36 +08:00
el += '<a href="' + item.url + '"';
if (item.url.includes('://')) {
el += ' target="_blank" rel="external nofollow noopener noreferrer">';
} else {
el += ' rel="noopener noreferrer">';
}
2021-02-25 20:49:43 +08:00
el += item.title || item.url;
2021-02-25 00:05:23 +08:00
el += '</a>';
el += '</li>';
2021-02-19 23:33:19 +08:00
});
2021-02-25 00:05:23 +08:00
el += '</ul></div>';
el += '</section>';
2021-02-19 23:33:19 +08:00
}
2021-02-25 00:05:23 +08:00
2021-02-25 13:12:04 +08:00
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>';
}
2021-02-25 00:05:23 +08:00
2021-02-25 13:12:04 +08:00
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>';
2021-03-08 15:26:52 +08:00
el += '<div class="social-wrap dis-select">';
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;
2022-11-06 19:46:47 +08:00
el += '&title=' + (page.seo_title || (page.title + ' - ' + config.title));
if (page.layout == 'post' && page.cover) {
2021-02-25 13:12:04 +08:00
el += '&pics=' + page.cover;
} else if (page.layout == 'wiki' && page.logo && page.logo.src) {
2021-02-25 13:12:04 +08:00
el += '&pics=' + page.logo.src;
}
el += '&summary=' + truncate(page.description || strip_html(page.excerpt || page.content), {length: 120});
el += '"';
} else if (item == 'email') {
2022-11-06 19:46:47 +08:00
el += ' href="mailto:?subject=' + ((page.title + ' - ' + config.title) || page.seo_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 += '>';
if (item == 'wechat') {
2022-12-20 00:09:34 +08:00
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.4/social/b32ef3da1162a.svg"/>';
2021-02-25 13:12:04 +08:00
} else if (item == 'weibo') {
2022-12-20 00:09:34 +08:00
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.4/social/80c07e4dbb303.svg"/>';
2021-02-25 13:12:04 +08:00
} else if (item == 'email') {
2022-12-20 00:09:34 +08:00
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.4/social/a1b00e20f425d.svg"/>';
2021-02-25 13:12:04 +08:00
} else if (item == 'link') {
2022-12-20 00:09:34 +08:00
el += '<img src="https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.4/social/8411ed322ced6.svg"/>';
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
});
el += '</div>';
if (theme.article.share.includes('wechat')) {
2021-03-08 15:26:52 +08:00
el += '<div class="qrcode" id="qrcode-wechat" style="visibility:hidden;height:0">';
el += '<img src="https://api.qrserver.com/v1/create-qr-code/?size=256x256&data=' + page.permalink + '"/>';
2021-02-25 13:12:04 +08:00
el += '</div>';
2021-02-25 00:05:23 +08:00
}
2021-02-25 13:12:04 +08:00
el += '</div>';
el += '</section>';
}
2021-02-25 00:05:23 +08:00
}
el += '</div>';
return el;
2021-02-19 23:33:19 +08:00
}
%>
<%- layoutDiv(); %>