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>
|
|
|
|
<a class='cap-action' id='s-top' title='<%- __("meta.back_to_top") %>' href='#start'>
|
|
|
|
<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10505"><path d="M884.526 163.323H208.881c-30.516 0-55.25 24.934-55.25 55.685s24.734 55.685 55.25 55.685h675.645c30.515 0 55.255-24.93 55.255-55.685s-24.74-55.685-55.255-55.685zM568.253 336.87a56.765 56.765 0 0 0-4.06-3.701c-0.63-0.517-1.29-0.968-1.935-1.454-0.799-0.605-1.577-1.224-2.406-1.787-0.779-0.528-1.583-0.978-2.386-1.46-0.748-0.45-1.485-0.926-2.253-1.341-0.81-0.44-1.649-0.814-2.483-1.208-0.8-0.384-1.588-0.784-2.407-1.132-0.814-0.338-1.643-0.61-2.463-0.906-0.875-0.323-1.745-0.66-2.641-0.932-0.825-0.25-1.66-0.435-2.489-0.645-0.916-0.236-1.817-0.492-2.75-0.681-0.962-0.19-1.935-0.307-2.902-0.445-0.814-0.118-1.618-0.272-2.442-0.354a55.163 55.163 0 0 0-5.438-0.276h-0.015c-0.267 0-0.528 0.036-0.794 0.036a54.856 54.856 0 0 0-39.86 16.271l-279.413 281.61c-21.576 21.75-21.576 57.006 0 78.756a54.876 54.876 0 0 0 39.07 16.312 54.835 54.835 0 0 0 39.066-16.312l186.67-188.145V898.09c0 30.75 24.74 55.685 55.256 55.685s55.255-24.934 55.255-55.685v-387.42L769.526 697.22a54.871 54.871 0 0 0 39.065 16.312 54.835 54.835 0 0 0 39.066-16.312c21.576-21.75 21.576-57.006 0-78.756L568.253 336.87z" p-id="10506"></path></svg>
|
|
|
|
</a>
|
|
|
|
</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>
|
|
|
|
<% } %>
|