<% // 默认组件 if (page.sidebar == undefined) { if (page.layout == 'post' && page.content) { page.sidebar = theme.sidebar.widgets.post; } else if (page.layout == 'wiki' && page.wiki) { let proj = theme.wiki.tree[page.wiki]; if (proj?.sidebar) { page.sidebar = proj.sidebar; } else { page.sidebar = theme.sidebar.widgets.wiki; } } else if (page.layout === 'topic') { if (page.topic && theme.topic?.tree[page.topic]?.sidebar) { page.sidebar = theme.topic.tree[page.topic].sidebar; } else { page.sidebar = theme.sidebar.widgets.topic; } } else if (page.layout === 'index_topic') { page.sidebar = theme.sidebar.widgets.index_topic } else if (is_home()) { page.sidebar = theme.sidebar.widgets.home; } else if (is_category() || is_tag() || is_archive() || ['categories', 'tags', 'archives'].includes(page.layout)) { page.sidebar = theme.sidebar.widgets.blog_index; } else if (['wiki_index'].includes(page.layout)) { page.sidebar = theme.sidebar.widgets.wiki_index; } else if (['404', undefined].includes(page.layout)) { page.sidebar = theme.sidebar.widgets.others; } else if (page.layout == 'page') { page.sidebar = theme.sidebar.widgets.page; } else { page.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 = ''; el += '
'; if (page.layout == 'wiki' && proj && page.menu_id == 'wiki') { el += '
'; // all products el += ''; el += ''; el += __('btn.all_wiki'); el += ''; // this product var proj; if (page.layout === 'wiki' && page.wiki) { proj = theme.wiki.tree[page.wiki]; } if (proj == undefined) { // 如果没有项目名,则使用menu中显示的名字 if (page.menu_id && theme.sidebar.menu[page.menu_id] && md_link(theme.sidebar.menu[page.menu_id])) { proj = { path: md_link(theme.sidebar.menu[page.menu_id]), wiki: __(md_text(theme.sidebar.menu[page.menu_id])) }; } } if (proj != undefined) { let main = proj.name || proj.title || page.wiki || page.title; let url = proj.homepage.path; let sub = proj.subtitle; el += layoutTitle(main, url, sub); } 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 = '