hexo-theme-stellar/layout/_partial/sidebar/index.ejs

44 lines
1.2 KiB
Plaintext
Raw Normal View History

2021-02-19 23:33:19 +08:00
<%
// 默认组件
if (page.sidebar == undefined) {
if (page.layout == 'post' && page.content) {
page.sidebar = ['toc', 'recent'];
} else if (page.layout == 'wiki' && page.content) {
page.sidebar = ['toc', 'wiki_more'];
} else {
2021-02-25 20:49:43 +08:00
page.sidebar = theme.sidebar.widgets.default;
2021-02-19 23:33:19 +08:00
}
}
function layoutFooterDiv() {
if (theme.footer.social && theme.footer.social.length > 0) {
2021-03-05 21:37:28 +08:00
var el = '<footer class="footer"><div class="social-wrap dis-select">';
2021-02-19 23:33:19 +08:00
theme.footer.social.forEach(item => {
if (item.icon && item.url) {
2021-02-27 20:08:36 +08:00
el += '<a class="social" href="' + url_for(item.url) + '"';
if (item.url.includes('://')) {
el += ' target="_blank" rel="external nofollow noopener noreferrer">';
} else {
el += ' rel="noopener noreferrer">';
}
el += item.icon;
el += '</a>';
2021-02-19 23:33:19 +08:00
}
});
el += '</div></footer>';
return el;
} else {
return '';
}
}
%>
2021-03-05 21:37:28 +08:00
<%- partial('header', {where: 'sidebar'}) %>
<div class='widgets'>
<% page.sidebar.forEach(function(widget){ %>
<% if (widget in theme.sidebar.widgets) { %>
<% let w = theme.sidebar.widgets[widget]; %>
<%- partial('widgets/' + w.layout, {item: w}) %>
<% } %>
<% }) %>
2021-02-19 23:33:19 +08:00
</div>
2021-03-05 21:37:28 +08:00
<%- layoutFooterDiv() %>