Skip to content

Commit

Permalink
Reduce files and keep only those required at runtime 7b2b507
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyib committed Jan 2, 2021
1 parent fe1197a commit 39b5916
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions source/js/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ $(document).ready(function () {
return
}
if (currHeading !== lastHeading) {
var anchor = window.decodeURIComponent(currHeading)
var $targetLink = $('.sidebar-toc a[href="#' + anchor + '"]')
var $targetLink = $('.sidebar-toc a[href="#' + currHeading + '"]')

// In order to be compatible with Hexo under v5.0.0
if (!$targetLink.length) {
var anchorDecode = window.decodeURIComponent(currHeading)
$targetLink = $('.sidebar-toc a[href="#' + anchorDecode + '"]')
}

$allTocItem.removeClass('active current')
$targetLink.parents('li').addClass('active')
$targetLink.parent().addClass('current')
Expand Down

0 comments on commit 39b5916

Please sign in to comment.