54 lines
1.6 KiB
Plaintext
Executable File
54 lines
1.6 KiB
Plaintext
Executable File
<%
|
|
// 默认组件
|
|
if (page.sidebar == undefined) {
|
|
if (page.layout == 'post' && page.content) {
|
|
page.sidebar = ['toc'];
|
|
} else if (page.layout == 'wiki' && page.content) {
|
|
page.sidebar = ['toc', 'wiki_more'];
|
|
} else {
|
|
page.sidebar = theme.sidebar.widgets.default;
|
|
}
|
|
}
|
|
function layoutFooterDiv() {
|
|
if (theme.footer.social && theme.footer.social.length > 0) {
|
|
var el = '<footer class="footer dis-select"><div class="social-wrap">';
|
|
theme.footer.social.forEach(item => {
|
|
if (item.icon && (item.url || item.onclick)) {
|
|
el += '<a class="social"';
|
|
if (item.title) {
|
|
el += ' title="' + item.title + '"';
|
|
}
|
|
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 + '"';
|
|
}
|
|
el += '>';
|
|
el += item.icon;
|
|
el += '</a>';
|
|
}
|
|
});
|
|
el += '</div></footer>';
|
|
return el;
|
|
} else {
|
|
return '';
|
|
}
|
|
}
|
|
%>
|
|
<%- 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}) %>
|
|
<% } %>
|
|
<% }) %>
|
|
</div>
|
|
<%- layoutFooterDiv() %>
|