@@ -32,13 +32,13 @@ export default (cli) => {
3232 // First pass to create parents
3333 metaKeys . forEach ( ( key ) => {
3434 // Check for existing primary nav
35- const idx = nav . findIndex ( ( parent ) => parent . title === meta [ key ] ?. nav . parent )
35+ const idx = nav . findIndex ( ( parent ) => parent . title . trim ( ) === meta [ key ] ?. nav . parent . trim ( ) )
3636
3737 // Make new nav group if necessary
3838 if ( idx < 0 ) {
3939 nav . push ( {
40- title : meta [ key ] . nav . parent ,
41- alt : `Choose a ${ meta [ key ] . nav . parent } ` ,
40+ title : meta [ key ] . nav . parent . trim ( ) ,
41+ alt : `Choose a ${ meta [ key ] . nav . parent . trim ( ) } ` ,
4242 href : '#' ,
4343 links : [ ] ,
4444 } )
@@ -48,14 +48,14 @@ export default (cli) => {
4848 // Second Pass to create groups within parents
4949 metaKeys . forEach ( ( key ) => {
5050 // Check for existing primary nav
51- const idx = nav . findIndex ( ( parent ) => parent . title === meta [ key ] ?. nav . parent )
52- const groupIdx = nav [ idx ] . links . findIndex ( ( group ) => group . title === meta [ key ] ?. nav . child )
51+ const idx = nav . findIndex ( ( parent ) => parent . title . trim ( ) === meta [ key ] ?. nav . parent . trim ( ) )
52+ const groupIdx = nav [ idx ] . links . findIndex ( ( group ) => group . title . trim ( ) === meta [ key ] ?. nav . child . trim ( ) )
5353
5454 // Make new nav group if necessary
5555 if ( groupIdx < 0 ) {
5656 nav [ idx ] . links . push ( {
57- title : meta [ key ] . nav . child ,
58- alt : `${ meta [ key ] ?. nav . parent } › ${ meta [ key ] . nav . child } ` ,
57+ title : meta [ key ] . nav . child . trim ( ) ,
58+ alt : `${ meta [ key ] ?. nav . parent . trim ( ) } › ${ meta [ key ] . nav . child . trim ( ) } ` ,
5959 href : '#' ,
6060 children : [ ] ,
6161 } )
@@ -65,26 +65,26 @@ export default (cli) => {
6565 // Last pass to create links within groups
6666 metaKeys . forEach ( ( key ) => {
6767 // Check for existing primary nav
68- const idx = nav . findIndex ( ( parent ) => parent . title === meta [ key ] ?. nav . parent )
69- const groupIdx = nav [ idx ] . links . findIndex ( ( group ) => group . title === meta [ key ] ?. nav . child )
68+ const idx = nav . findIndex ( ( parent ) => parent . title . trim ( ) === meta [ key ] ?. nav . parent . trim ( ) )
69+ const groupIdx = nav [ idx ] . links . findIndex ( ( group ) => group . title . trim ( ) === meta [ key ] ?. nav . child . trim ( ) )
7070
7171 if ( idx > - 1 && groupIdx > - 1 ) {
7272 nav [ idx ] . links [ groupIdx ] . children . push ( {
73- title : meta [ key ] . nav . title ,
74- alt : meta [ key ] . nav . alt ,
73+ title : meta [ key ] . nav . title . trim ( ) ,
74+ alt : meta [ key ] . nav . alt . trim ( ) ,
7575 href : meta [ key ] . deprecated ? `/deprecated${ key } ` : key ,
7676 deprecated : meta [ key ] . deprecated ,
7777 } )
7878 }
7979 } )
8080
8181 // Sort all the things
82- nav . sort ( ( a , b ) => ( a . title > b . title ? 1 : - 1 ) )
83- nav . forEach ( ( page ) => page . links . sort ( ( a , b ) => ( a . title > b . title ? 1 : - 1 ) ) )
82+ nav . sort ( ( a , b ) => ( a . title . trim ( ) > b . title . trim ( ) ? 1 : - 1 ) )
83+ nav . forEach ( ( page ) => page . links . sort ( ( a , b ) => ( a . title . trim ( ) > b . title . trim ( ) ? 1 : - 1 ) ) )
8484 nav . forEach ( ( page ) =>
8585 page . links . forEach ( ( sub ) => {
8686 if ( sub . children ) {
87- sub . children . sort ( ( a , b ) => ( a . title > b . title ? 1 : - 1 ) )
87+ sub . children . sort ( ( a , b ) => ( a . title . trim ( ) > b . title . trim ( ) ? 1 : - 1 ) )
8888 }
8989 } )
9090 )
0 commit comments