% const wiki = theme.wiki.tree[page.wiki] const topic = theme.topic.tree[page.topic] if (page.rightbar == null) { const { site_tree } = theme var sidebar if (is_home()) { sidebar = site_tree.home.rightbar } else if (is_category() || is_tag() || is_archive() || ['categories', 'tags', 'archives'].includes(page.layout)) { sidebar = site_tree.index_blog.rightbar } else if (page.layout === 'index_topic') { // 专栏列表页等同于博客列表页 sidebar = site_tree.index_blog.rightbar } else if (page.topic?.length > 0) { // 专栏文章内页等同于普通文章内页 sidebar = site_tree.post.rightbar } else if (page.layout === 'index_wiki') { sidebar = site_tree.index_wiki.rightbar } else if (page.wiki?.length > 0) { sidebar = site_tree.wiki.rightbar } else if (page.layout === '404') { sidebar = site_tree.error_page.rightbar } else if (page.layout === 'page') { sidebar = site_tree.page.rightbar } else if (page.layout === 'post') { sidebar = site_tree.post.rightbar } else if (page.layout == null) { sidebar = site_tree.page.rightbar } else { sidebar = [] } if (topic?.rightbar) { sidebar = topic.rightbar } if (wiki?.rightbar) { sidebar = wiki.rightbar } page.rightbar = sidebar } // parse array string if (typeof page.rightbar == 'string') { page.rightbar = page.rightbar.replace(/ /g, '').split(','); } function layoutWidgets() { var el = ''; el += '
'; return el; } %> <%- layoutWidgets() %>