%
if (page.sidebar == null) {
const { site_tree } = theme
var sidebar
if (is_home()) {
sidebar = site_tree.home.sidebar
} else if (is_category() || is_tag() || is_archive() || ['categories', 'tags', 'archives'].includes(page.layout)) {
sidebar = site_tree.blog.sidebar
} else if (page.layout === 'index_topic') {
// 专栏列表页等同于博客列表页
sidebar = site_tree.blog.sidebar
} else if (page.layout === 'topic') {
sidebar = site_tree.topic.sidebar
} else if (page.layout === 'index_wiki' || page.layout === 'wiki') {
sidebar = site_tree.wiki.sidebar
} else if (page.layout === '404') {
sidebar = site_tree.error_page.sidebar
} else if (page.layout === 'page') {
sidebar = site_tree.page.sidebar
} else if (page.layout === 'post') {
sidebar = site_tree.post.sidebar
} else if (page.layout == null) {
sidebar = site_tree.page.sidebar
} else {
sidebar = []
}
if (page.layout === 'topic' && page.topic && theme.topic?.tree[page.topic]?.sidebar) {
sidebar = theme.topic.tree[page.topic].sidebar
}
if (page.layout == 'wiki' && page.wiki && theme.wiki?.tree[page.wiki]?.sidebar) {
sidebar = theme.wiki.tree[page.wiki].sidebar
}
page.sidebar = sidebar
}
// parse array string
if (typeof page.sidebar == 'string') {
page.sidebar = page.sidebar.replace(/ /g, '').split(',');
}
function layoutTitle(main, url, sub) {
var el = '';
el += '';
el += '' + main + '
';
if (sub) {
let arr = sub.split('|');
if (arr.length > 1) {
el += '' + arr.shift().trim() + '
';
el += '' + arr.join('|') + '
';
} else {
el += '' + sub + '
';
}
}
el += '';
return el;
}
function layoutWidgets() {
var el = '';
var proj;
if (page.layout === 'wiki' && page.wiki) {
proj = theme.wiki.tree[page.wiki];
}
el += '
';
if (page.sidebar) {
page.sidebar.forEach((w, i) => {
let name = ''
let widget = {}
if (typeof w == 'string') {
name = w
} else if (typeof w == 'object' && w.override) {
name = w.override
}
if (name in theme.data.widgets) {
Object.assign(widget, theme.data.widgets[name])
}
if (typeof w == 'object' && (w.override || w.layout)) {
Object.assign(widget, w)
}
if (widget && widget.layout) {
el += partial('../widgets/' + widget.layout, {item: widget})
}
});
}
el += '
';
return el;
}
function layoutFooterDiv() {
const { social } = theme.footer
if (social == null) {
return ''
}
var el = '';
return el;
}
function layoutLogo() {
return partial('logo', {where: 'sidebar'})
}
function layoutNavArea() {
var search = {}
if (page.search) {
search = page.search
} else if (page.wiki && page.layout == 'wiki' && theme.wiki.tree[page.wiki]) {
const proj = theme.wiki.tree[page.wiki]
if (proj.search) {
search = proj.search
}
} else if (page.topic && page.layout == 'topic' && theme.topic.tree[page.topic]) {
const topic = theme.topic.tree[page.topic]
if (topic.search) {
search = topic.search
}
}
var el = ''
el += ``
el += partial('search', {item: search})
el += partial('menu', {where: 'sidebar'})
el += `
`
return el
}
%>
<%- layoutLogo() %>
<%- layoutNavArea() %>
<%- layoutWidgets() %>
<%- layoutFooterDiv() %>