%
const wiki = theme.wiki.tree[page.wiki]
const topic = theme.topic.tree[page.topic]
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.index_blog.sidebar
} else if (page.layout === 'index_topic') {
// 专栏列表页等同于博客列表页
sidebar = site_tree.index_blog.sidebar
} else if (page.topic?.length > 0) {
// 专栏文章内页等同于普通文章内页
sidebar = site_tree.post.sidebar
} else if (page.layout === 'index_wiki') {
sidebar = site_tree.index_wiki.sidebar
} else if (page.wiki?.length > 0) {
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 (topic?.sidebar) {
sidebar = topic.sidebar
}
if (wiki?.sidebar) {
sidebar = 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 += '