2025-2-26-fixed
This commit is contained in:
49
themes/fluid/layout/_partials/post/toc.ejs
Normal file
49
themes/fluid/layout/_partials/post/toc.ejs
Normal file
@ -0,0 +1,49 @@
|
||||
<div id="toc">
|
||||
<p class="toc-header">
|
||||
<i class="iconfont icon-list"></i>
|
||||
<span><%- __('post.toc') %></span>
|
||||
</p>
|
||||
<div class="toc-body" id="toc-body"></div>
|
||||
</div>
|
||||
|
||||
<%
|
||||
import_script(`
|
||||
<script>
|
||||
Fluid.utils.createScript('${url_join(theme.static_prefix.tocbot, 'tocbot.min.js')}', function() {
|
||||
var toc = jQuery('#toc');
|
||||
if (toc.length === 0 || !window.tocbot) { return; }
|
||||
var boardCtn = jQuery('#board-ctn');
|
||||
var boardTop = boardCtn.offset().top;
|
||||
|
||||
window.tocbot.init(Object.assign({
|
||||
tocSelector : '#toc-body',
|
||||
contentSelector : '.markdown-body',
|
||||
linkClass : 'tocbot-link',
|
||||
activeLinkClass : 'tocbot-active-link',
|
||||
listClass : 'tocbot-list',
|
||||
isCollapsedClass: 'tocbot-is-collapsed',
|
||||
collapsibleClass: 'tocbot-is-collapsible',
|
||||
scrollSmooth : true,
|
||||
includeTitleTags: true,
|
||||
headingsOffset : -boardTop,
|
||||
}, CONFIG.toc));
|
||||
if (toc.find('.toc-list-item').length > 0) {
|
||||
toc.css('visibility', 'visible');
|
||||
}
|
||||
|
||||
Fluid.events.registerRefreshCallback(function() {
|
||||
if ('tocbot' in window) {
|
||||
tocbot.refresh();
|
||||
var toc = jQuery('#toc');
|
||||
if (toc.length === 0 || !tocbot) {
|
||||
return;
|
||||
}
|
||||
if (toc.find('.toc-list-item').length > 0) {
|
||||
toc.css('visibility', 'visible');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
`)
|
||||
%>
|
||||
Reference in New Issue
Block a user