@@ -559,7 +559,15 @@ function hideThemeButtonState() {
559
559
others . appendChild ( div ) ;
560
560
}
561
561
562
- function block ( shortty , longty ) {
562
+ /**
563
+ * Append to the sidebar a "block" of links - a heading along with a list (`<ul>`) of items.
564
+ *
565
+ * @param {string } shortty - A short type name, like "primitive", "mod", or "macro"
566
+ * @param {string } id - The HTML id of the corresponding section on the module page.
567
+ * @param {string } longty - A long, capitalized, plural name, like "Primitive Types",
568
+ * "Modules", or "Macros".
569
+ */
570
+ function block ( shortty , id , longty ) {
563
571
var filtered = items [ shortty ] ;
564
572
if ( ! filtered ) {
565
573
return ;
@@ -568,7 +576,7 @@ function hideThemeButtonState() {
568
576
var div = document . createElement ( "div" ) ;
569
577
div . className = "block " + shortty ;
570
578
var h3 = document . createElement ( "h3" ) ;
571
- h3 . textContent = longty ;
579
+ h3 . innerHTML = `<a href="index.html# ${ id } "> ${ longty } </a>` ;
572
580
div . appendChild ( h3 ) ;
573
581
var ul = document . createElement ( "ul" ) ;
574
582
@@ -607,20 +615,20 @@ function hideThemeButtonState() {
607
615
608
616
var isModule = hasClass ( document . body , "mod" ) ;
609
617
if ( ! isModule ) {
610
- block ( "primitive" , "Primitive Types" ) ;
611
- block ( "mod" , "Modules" ) ;
612
- block ( "macro" , "Macros" ) ;
613
- block ( "struct" , "Structs" ) ;
614
- block ( "enum" , "Enums" ) ;
615
- block ( "union" , "Unions" ) ;
616
- block ( "constant" , "Constants" ) ;
617
- block ( "static" , "Statics" ) ;
618
- block ( "trait" , "Traits" ) ;
619
- block ( "fn" , "Functions" ) ;
620
- block ( "type" , "Type Definitions" ) ;
621
- block ( "foreigntype" , "Foreign Types" ) ;
622
- block ( "keyword" , "Keywords" ) ;
623
- block ( "traitalias" , "Trait Aliases" ) ;
618
+ block ( "primitive" , "primitives" , " Primitive Types") ;
619
+ block ( "mod" , "modules" , " Modules") ;
620
+ block ( "macro" , "macros" , " Macros") ;
621
+ block ( "struct" , "structs" , " Structs") ;
622
+ block ( "enum" , "enums" , " Enums") ;
623
+ block ( "union" , "unions" , " Unions") ;
624
+ block ( "constant" , "constants" , " Constants") ;
625
+ block ( "static" , "static" , " Statics") ;
626
+ block ( "trait" , "traits" , " Traits") ;
627
+ block ( "fn" , "functions" , " Functions") ;
628
+ block ( "type" , "types" , " Type Definitions") ;
629
+ block ( "foreigntype" , "foreign-types" , " Foreign Types") ;
630
+ block ( "keyword" , "keywords" , " Keywords") ;
631
+ block ( "traitalias" , "trait-aliases" , " Trait Aliases") ;
624
632
}
625
633
626
634
// `crates{version}.js` should always be loaded before this script, so we can use
0 commit comments