diff options
author | noaione <noaione0809@gmail.com> | 2021-03-04 08:02:32 +0300 |
---|---|---|
committer | noaione <noaione0809@gmail.com> | 2021-03-04 08:02:32 +0300 |
commit | ec5d6dcebe1b98af283fafb7ab2413dadb616dec (patch) | |
tree | f235ca5dbbd36c5c6054cae465a0a4c67da03eb6 | |
parent | 5a45e2eb974f1068da49d1da7e048a6f857be8da (diff) |
fix: ToC not highlighting properly
-rw-r--r-- | src/js/theme.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/js/theme.js b/src/js/theme.js index 0a16d7c..f7a30e1 100644 --- a/src/js/theme.js +++ b/src/js/theme.js @@ -454,7 +454,18 @@ class Theme { $toc.style.position = 'fixed'; $toc.style.top = `${TOP_SPACING}px`; } - + // Check if there's subtitle + const $subtitleLinkElem = document.getElementsByClassName("single-subtitle headerLink"); + let tocSubtract = $subtitleLinkElem.length > 0 ? 2 : 1; + + // Check if there's embedded gist markdown + let $embeddedGists = [] + this.util.forEach($headerLinkElements, $headerElem => { + if ($headerElem.parentNode.nodeName === "ARTICLE") { + $embeddedGists.push($headerElem); + } + }) + tocSubtract += $embeddedGists.length; this.util.forEach($tocLinkElements, $tocLink => { $tocLink.classList.remove('active'); }); @@ -471,6 +482,7 @@ class Theme { break; } } + activeTocIndex -= tocSubtract; if (activeTocIndex !== -1) { $tocLinkElements[activeTocIndex].classList.add('active'); let $parent = $tocLinkElements[activeTocIndex].parentElement; |