2021-02-19 23:33:19 +08:00
|
|
|
<%
|
2024-02-05 10:03:55 +08:00
|
|
|
|
2024-01-14 01:39:02 +08:00
|
|
|
function layoutTocBody() {
|
2021-02-19 23:33:19 +08:00
|
|
|
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
|
2024-02-05 10:03:55 +08:00
|
|
|
})
|
2021-02-19 23:33:19 +08:00
|
|
|
}
|
2024-01-13 21:10:26 +08:00
|
|
|
return ''
|
2021-02-19 23:33:19 +08:00
|
|
|
}
|
2021-07-25 22:47:18 +08:00
|
|
|
|
|
|
|
function layoutTocHeader(title) {
|
2024-01-14 01:39:02 +08:00
|
|
|
var el = ''
|
2024-01-17 22:57:52 +08:00
|
|
|
el += `<div class="widget-header dis-select">`
|
2024-01-14 01:39:02 +08:00
|
|
|
el += `<span class="name">${title || __("meta.toc")}</span>`
|
2024-02-05 18:01:50 +08:00
|
|
|
el += `<a class="cap-action" onclick="sidebar.toggleTOC()" >${icon('default:rightbar')}</a>`
|
2024-01-14 01:39:02 +08:00
|
|
|
el += `</div>`
|
|
|
|
return el
|
2021-07-25 22:47:18 +08:00
|
|
|
}
|
|
|
|
|
2024-02-05 18:01:50 +08:00
|
|
|
function layoutToc(fallback) {
|
2024-02-05 10:03:55 +08:00
|
|
|
const tocBody = layoutTocBody()
|
|
|
|
if (tocBody.length == 0) {
|
|
|
|
return ''
|
2021-04-07 21:34:11 +08:00
|
|
|
}
|
2024-01-14 01:39:02 +08:00
|
|
|
var el = ''
|
2024-02-05 10:03:55 +08:00
|
|
|
el += `<widget class="widget-wrapper${scrollreveal(' ')} toc" id="data-toc" collapse="${item.collapse}">`
|
|
|
|
el += layoutTocHeader()
|
|
|
|
el += `<div class="widget-body">`
|
|
|
|
el += tocBody
|
|
|
|
el += `</div>`
|
|
|
|
el += `</widget>`
|
2024-01-14 01:39:02 +08:00
|
|
|
return el
|
2021-04-07 21:34:11 +08:00
|
|
|
}
|
|
|
|
|
2024-02-05 18:01:50 +08:00
|
|
|
function layoutDiv(fallback) {
|
|
|
|
const editBtn = partial('components/edit', {map: item.edit_this_page})
|
|
|
|
const tocBody = layoutTocBody()
|
2024-02-05 22:55:10 +08:00
|
|
|
if (tocBody.trim().length == 0 && editBtn.trim().length == 0) {
|
2024-02-05 18:01:50 +08:00
|
|
|
return ''
|
|
|
|
}
|
|
|
|
var el = ''
|
|
|
|
el += `<widget class="widget-wrapper${scrollreveal(' ')} toc" id="data-toc" collapse="${item.collapse}">`
|
|
|
|
if (tocBody.length > 0) {
|
|
|
|
el += layoutTocHeader()
|
|
|
|
el += `<div class="widget-body">`
|
|
|
|
el += tocBody
|
|
|
|
el += `</div>`
|
|
|
|
}
|
2024-02-05 22:55:10 +08:00
|
|
|
el += `<div class="widget-footer">`
|
|
|
|
el += editBtn
|
|
|
|
el += `<a class="top" onclick="util.scrollTop()">`
|
|
|
|
el += icon('default:upup')
|
|
|
|
el += `<span>${__('btn.top')}</span>`
|
|
|
|
el += `</a>`
|
2024-04-11 11:04:52 +08:00
|
|
|
if (page.comments) {
|
|
|
|
el += `<a class="buttom" onclick="util.scrollComment()">`
|
|
|
|
el += icon('default:tocomment')
|
|
|
|
el += `<span>${__('btn.comments')}</span>`
|
|
|
|
el += `</a>`
|
|
|
|
}
|
2024-02-05 22:55:10 +08:00
|
|
|
el += `</div>`
|
2024-02-05 18:01:50 +08:00
|
|
|
el += `</widget>`
|
|
|
|
return el
|
|
|
|
}
|
|
|
|
|
2021-04-07 21:34:11 +08:00
|
|
|
%>
|
2021-07-25 22:47:18 +08:00
|
|
|
|
|
|
|
<%- layoutDiv() %>
|