2021-02-19 23:33:19 +08:00
|
|
|
<%
|
|
|
|
var enable = false;
|
|
|
|
if (page.layout == 'post') {
|
|
|
|
if (page.content && toc(page.content).length > 0) {
|
|
|
|
enable = true;
|
|
|
|
}
|
|
|
|
} else if (page.layout == 'wiki' || page.sidebar.includes('toc') == true) {
|
|
|
|
enable = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function layout_toc() {
|
|
|
|
if (toc(page.content).length > 0) {
|
|
|
|
return toc(page.content, {
|
|
|
|
list_number: item.list_number,
|
|
|
|
min_depth: item.min_depth,
|
|
|
|
max_depth: item.max_depth
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%>
|
|
|
|
<% if (enable == true) { %>
|
|
|
|
<div class='widget-wrap' id='toc'>
|
2021-03-05 21:37:28 +08:00
|
|
|
<div class='widget-header h4 dis-select'>
|
2021-02-19 23:33:19 +08:00
|
|
|
<span class='name'>
|
|
|
|
<% if (page.toc_title) { %>
|
|
|
|
<%- page.toc_title %>
|
|
|
|
<% } else if (page.layout == 'wiki') { %>
|
|
|
|
<%- page.wiki || item.wiki %>
|
|
|
|
<% } else { %>
|
|
|
|
<%- __('meta.toc') %>
|
|
|
|
<% } %>
|
|
|
|
</span>
|
|
|
|
</div>
|
2021-03-05 21:37:28 +08:00
|
|
|
<div class='widget-body fs14 <%- page.layout == "wiki" ? "wiki" : "post" %>'>
|
2021-02-19 23:33:19 +08:00
|
|
|
<% if (page.layout == 'wiki' && page.wiki) { %>
|
|
|
|
<%
|
|
|
|
var wikis = [];
|
|
|
|
wikis = site.pages.filter(function (p) {
|
2021-02-22 13:19:21 +08:00
|
|
|
if (p.layout == 'wiki' && p.wiki && p.wiki == page.wiki && (p.title || p.seo_title)) {
|
2021-02-19 23:33:19 +08:00
|
|
|
if (p.order == undefined) {
|
|
|
|
p.order = 0;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}).sort('order');
|
|
|
|
%>
|
|
|
|
<% if (wikis.length > 1) { %>
|
|
|
|
<% wikis.each(function(p) { %>
|
|
|
|
<% if (p.path == page.path) { %>
|
|
|
|
<div class='doc-tree active'>
|
|
|
|
<a class='doc-tree-link active' href="<%- url_for(p.path) %>"><span class="toc-text"><%- p.title || p.seo_title %></span></a>
|
|
|
|
<%- layout_toc() %>
|
|
|
|
</div>
|
|
|
|
<% } else { %>
|
|
|
|
<div class='doc-tree'>
|
|
|
|
<a class='doc-tree-link' href="<%- url_for(p.path) %>"><span class="toc-text"><%- p.title || p.seo_title %></span></a>
|
|
|
|
</div>
|
|
|
|
<% } %>
|
|
|
|
<% }); %>
|
|
|
|
<% } else { %>
|
|
|
|
<div class='doc-tree active'>
|
|
|
|
<%- layout_toc() %>
|
|
|
|
</div>
|
|
|
|
<% } %>
|
|
|
|
<% } else { %>
|
|
|
|
<div class='doc-tree active'>
|
|
|
|
<%- layout_toc() %>
|
|
|
|
</div>
|
|
|
|
<% } %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<% } %>
|