hexo-theme-stellar/layout/_partial/widgets/toc.ejs

40 lines
807 B
Plaintext
Raw Normal View History

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>`
el += `</div>`
return el
2021-07-25 22:47:18 +08:00
}
2021-04-07 21:34:11 +08:00
function layoutDiv(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
}
%>
2021-07-25 22:47:18 +08:00
<%- layoutDiv() %>