File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,21 @@ document.addEventListener('click', (e) => {
3737 }
3838} ) ;
3939
40+ document . addEventListener ( 'DOMContentLoaded' , ( ) => {
41+ // need to correlate path to page rather than h1, as headers can be repeated (ie. nested1c/nested2-1 is seen the same as nested1b/nested2-1)
42+ const currentPage = document . querySelector ( "h1" ) . textContent ;
43+ console . log ( "This is a test log " + currentPage ) ;
44+
45+ const match = Array . from ( document . querySelectorAll ( ".sidebar__link" ) )
46+ . find ( el => el . textContent . includes ( currentPage ) ) ;
47+
48+ if ( match ) {
49+ console . log ( "Matching pair? " + match )
50+ match . scrollIntoView ( { behavior : "instant" , block : "nearest" } ) ;
51+ }
52+
53+ } ) ;
54+
4055const debounce = ( callback , wait ) => {
4156 let timeoutId = null ;
4257 return ( ...args ) => {
@@ -51,7 +66,7 @@ window.addEventListener(
5166 'resize' ,
5267 debounce ( ( ) => {
5368 const sidebar = document . getElementById ( 'sidebar-v2' ) ;
54-
69+ console . log ( "This is a test log" )
5570 if (
5671 window . innerWidth > 88 * 16 &&
5772 sidebar . classList . contains ( 'sidebar__mobile-open' )
@@ -60,3 +75,5 @@ window.addEventListener(
6075 }
6176 } , 200 )
6277) ;
78+
79+
You can’t perform that action at this time.
0 commit comments