%
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' || 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
}
console.log('s', 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() {
if (page.layout !== 'wiki' && theme.footer.social) {
var el = '';
return el;
} else {
return '';
}
}
function layoutLogo() {
var logo = theme.logo
if (page.logo) {
logo = page.logo
} else if (page.wiki && page.layout == 'wiki' && theme.wiki.tree[page.wiki]) {
const proj = theme.wiki.tree[page.wiki]
var l = proj.logo
if (l) {
logo = l
} else if (proj.name || proj.icon) {
logo = {
icon: proj.icon || theme.default.project,
title: `[${proj.name || proj.title}](${url_for(proj.homepage?.path || '')})`,
subtitle: proj.subtitle
}
}
} else if (page.topic && page.layout == 'topic' && theme.topic.tree[page.topic]) {
const topic = theme.topic.tree[page.topic]
var l = topic.logo
if (l) {
logo = l
} else if (topic.name || topic.icon) {
logo = {
icon: topic.icon || theme.default.topic,
title: `[${topic.name || topic.title}](${url_for(topic.homepage?.path || '')})`,
subtitle: topic.subtitle
}
}
}
return partial('logo', {logo: 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() %>