Przeglądaj źródła

Docs: Ensure navigation links are properly selected. (#22057)

* Docs: Ensure navigation links are properly selected.

* Docs: Simplify code.
Michael Herzog 4 lat temu
rodzic
commit
bb51c8f735
1 zmienionych plików z 9 dodań i 0 usunięć
  1. 9 0
      docs/index.html

+ 9 - 0
docs/index.html

@@ -238,6 +238,7 @@
 			}
 
 			const localList = list[ language ];
+			const selectedPage = window.location.hash.substring( 1 );
 
 			for ( const section in localList ) {
 
@@ -279,6 +280,14 @@
 						const linkElement = createLink( pageName, pageURL );
 						listElement.appendChild( linkElement );
 
+						// select current page
+
+						if ( pageURL === selectedPage ) {
+
+							linkElement.classList.add( 'selected' );
+
+						}
+
 						// Gather the main properties for the current subpage
 
 						pageProperties[ pageName ] = {