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) => {
37
37
}
38
38
} ) ;
39
39
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
+
40
55
const debounce = ( callback , wait ) => {
41
56
let timeoutId = null ;
42
57
return ( ...args ) => {
@@ -51,7 +66,7 @@ window.addEventListener(
51
66
'resize' ,
52
67
debounce ( ( ) => {
53
68
const sidebar = document . getElementById ( 'sidebar-v2' ) ;
54
-
69
+ console . log ( "This is a test log" )
55
70
if (
56
71
window . innerWidth > 88 * 16 &&
57
72
sidebar . classList . contains ( 'sidebar__mobile-open' )
@@ -60,3 +75,5 @@ window.addEventListener(
60
75
}
61
76
} , 200 )
62
77
) ;
78
+
79
+
You can’t perform that action at this time.
0 commit comments