File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 11document . addEventListener ( "DOMContentLoaded" , ( ) => {
22 const SCROLL_OFFSET = 70 ; // Adjust based on your header height
33 const TOC_SELECTOR_LEFT = '.md-nav__link' ; // Left nav links
4- const TOC_SELECTOR_RIGHT = '.md-nav__item--active ~ .md-nav__link' ; // Adjust for right nav if you have one
4+ const TOC_SELECTOR_RIGHT = '.md-nav--right .md-nav__link' ; // Right nav links (update selector as needed)
55
66 // Smooth scroll with offset
77 function scrollToHash ( hash ) {
@@ -18,7 +18,10 @@ document.addEventListener("DOMContentLoaded", () => {
1818
1919 // Update active TOC link
2020 function updateTOC ( ) {
21- const headings = document . querySelectorAll ( '.md-content__inner h1, .md-content__inner h2, .md-content__inner h3' ) ;
21+ const headings = document . querySelectorAll ( '.md-content__inner h1, .md-content__inner h2, .md-content__inner h3' ) ;
22+ if ( headings . length === 0 ) {
23+ return ;
24+ }
2225 const scrollPosition = window . scrollY + SCROLL_OFFSET + 5 ; // small buffer
2326
2427 let activeHeading = headings [ 0 ] ;
You can’t perform that action at this time.
0 commit comments