Skip to content

Commit

Permalink
fix: hexo-blog-decrypt TOC适配
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon committed Apr 27, 2024
1 parent 499cdbb commit 8f8a460
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ dark_mode:
firework:
enable: true
options:
excludeElements: ["a"]
excludeElements: ["a", "button"]
particles:
- shape: circle
move: ["emit"]
Expand Down
8 changes: 7 additions & 1 deletion layout/_partial/sidebar/toc-sidebar.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<div class="sidebar-toc">
<h3 class="toc-title"><%= __('toc') %></h3>
<div class="sidebar-toc-wrapper"><%- toc(page.content) %></div>
<div class="sidebar-toc-wrapper toc-div-class" <% if (page.encrypt == true) { %>style="display: none" <% } %>>
<% if (page.encrypt == true) { %>
<%- toc(page.origin) %>
<% } else { %>
<%- toc(page.content) %>
<% } %>
</div>
</div>
7 changes: 5 additions & 2 deletions source/js/pjax_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ var scrollIntoViewAndWait = (element) => {
$('body').removeClass('mobile-nav-on');
});

(function () {
function tocInit() {
const navItems = getComputedStyle(document.getElementById('sidebar')).display === 'block' ?
$('#sidebar .sidebar-toc-wrapper li') :
$('#mobile-nav .sidebar-toc-wrapper li');
Expand Down Expand Up @@ -302,5 +302,8 @@ var scrollIntoViewAndWait = (element) => {
sections.each(function () {
$(this).length && observer.observe($(this)[0])
})
})();
};

window.addEventListener('hexo-blog-decrypt', tocInit);
tocInit();
})(jQuery);

0 comments on commit 8f8a460

Please sign in to comment.