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-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 => {
|
2021-04-01 22:36:26 +08:00
|
|
|
if (item.icon && (item.url || item.onclick)) {
|
|
|
|
el += '<a class="social"';
|
|
|
|
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, '"');
|
|
|
|
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() %>
|