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

96 lines
3.5 KiB
Plaintext
Raw Normal View History

2021-02-19 23:33:19 +08:00
<%
function layoutDiv() {
2021-02-25 13:12:04 +08:00
if (page.layout == 'wiki' && !page.references) {
return '';
}
2021-02-25 00:05:23 +08:00
let el = '';
2021-02-25 20:49:43 +08:00
el += '<div class="article-footer">';
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">';
el += '<a href="' + item.url + '">';
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>';
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') {
2021-02-26 20:02:32 +08:00
el += ' onclick="util.toggle_qrcode()"';
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;
2021-02-25 13:12:04 +08:00
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') {
2021-02-26 20:02:32 +08:00
el += ' onclick="util.copy_link()"';
2021-02-25 13:12:04 +08:00
}
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>';
2021-02-25 00:05:23 +08:00
}
2021-02-25 13:12:04 +08:00
});
el += '</div>';
if (theme.article.share.includes('wechat')) {
el += '<div class="qrcode" id="qrcode-wechat" style="display:none">';
2021-02-26 20:02:32 +08:00
const src = qrcode(url,{margin:2,size:8});
2021-02-25 13:12:04 +08:00
el += '<img src="' + src + '"/>';
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(); %>