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

54 lines
1.6 KiB
Plaintext
Raw Normal View History

2021-02-19 23:33:19 +08:00
<%
// 默认组件
if (page.sidebar == undefined) {
if (page.layout == 'post' && page.content) {
2021-04-02 20:24:16 +08:00
page.sidebar = ['toc'];
2021-02-19 23:33:19 +08:00
} 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-07-03 22:33:52 +08:00
var el = '<footer class="footer dis-select"><div class="social-wrap">';
2021-02-19 23:33:19 +08:00
theme.footer.social.forEach(item => {
2021-04-01 22:36:26 +08:00
if (item.icon && (item.url || item.onclick)) {
el += '<a class="social"';
2021-06-23 16:39:21 +08:00
if (item.title) {
el += ' title="' + item.title + '"';
}
2021-04-01 22:36:26 +08:00
if (item.url) {
el += ' href="' + url_for(item.url) + '"';
if (item.url.includes('://')) {
el += ' target="_blank" rel="external nofollow noopener noreferrer"';
} else {
el += ' rel="noopener noreferrer"';
}
} else if (item.onclick) {
item.onclick = item.onclick.replace(/"|\'/g, '&quot;');
el += ' onclick="' + item.onclick + '"';
2021-02-27 20:08:36 +08:00
}
2021-04-01 22:36:26 +08:00
el += '>';
2021-02-27 20:08:36 +08:00
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() %>