File tree Expand file tree Collapse file tree 4 files changed +46
-38
lines changed Expand file tree Collapse file tree 4 files changed +46
-38
lines changed Original file line number Diff line number Diff line change 1+ --- 
2+ ' polaris.shopify.com ' patch 
3+ --- 
4+ 
5+ Refactor hideFromNav logic to support breadcrumbs
Original file line number Diff line number Diff line change @@ -11,45 +11,45 @@ const navJsonFile = `${cacheDir}/nav.json`;
1111const  genNavJson  =  ( markdownFiles )  =>  { 
1212  let  nav  =  { } ; 
1313
14-   markdownFiles 
15-     . filter ( ( md )  =>  md  &&  ! md . frontMatter ?. hideFromNav ) 
16-     . forEach ( ( md )  =>  { 
17-       const  { 
18-         title, 
19-         navTitle, 
20-         icon, 
21-         description, 
22-         order, 
23-         newSection, 
24-         hideChildren, 
25-         color, 
26-         url, 
27-         status, 
28-         expanded, 
29-         groups, 
30-         componentDescriptions, 
31-         relatedResources, 
32-       }  =  md . frontMatter ; 
33-       const  { slug}  =  md ; 
34- 
35-       const  path  =  `children.${ slug . replace ( / \/ / g,  '.children.' ) }  ; 
36- 
37-       set ( nav ,  path ,  { 
38-         title : navTitle  ||  title , 
39-         icon, 
40-         description, 
41-         order, 
42-         slug : url  ||  `/${ slug }  , 
43-         newSection, 
44-         hideChildren, 
45-         color : color  ? color . replace ( / \\ / g,  '' )  : undefined , 
46-         status, 
47-         expanded, 
48-         groups, 
49-         componentDescriptions, 
50-         relatedResources, 
51-       } ) ; 
14+   markdownFiles . forEach ( ( md )  =>  { 
15+     const  { 
16+       title, 
17+       navTitle, 
18+       icon, 
19+       description, 
20+       order, 
21+       newSection, 
22+       hideChildren, 
23+       color, 
24+       url, 
25+       status, 
26+       expanded, 
27+       groups, 
28+       componentDescriptions, 
29+       relatedResources, 
30+       hideFromNav, 
31+     }  =  md . frontMatter ; 
32+     const  { slug}  =  md ; 
33+ 
34+     const  path  =  `children.${ slug . replace ( / \/ / g,  '.children.' ) }  ; 
35+ 
36+     set ( nav ,  path ,  { 
37+       title : navTitle  ||  title , 
38+       icon, 
39+       description, 
40+       order, 
41+       slug : url  ||  `/${ slug }  , 
42+       newSection, 
43+       hideChildren, 
44+       color : color  ? color . replace ( / \\ / g,  '' )  : undefined , 
45+       status, 
46+       expanded, 
47+       groups, 
48+       componentDescriptions, 
49+       relatedResources, 
50+       hideFromNav : hideFromNav  ||  false , 
5251    } ) ; 
52+   } ) ; 
5353
5454  writeFileSync ( navJsonFile ,  JSON . stringify ( nav ) ,  'utf-8' ) ; 
5555} ; 
Original file line number Diff line number Diff line change @@ -194,7 +194,9 @@ function NavItem({
194194  return  ( 
195195    < > 
196196      { nav . children  && 
197+         ! nav . hideFromNav  && 
197198        Object . entries ( nav . children ) 
199+           . filter ( ( [ ,  child ] )  =>  ! child . hideFromNav ) 
198200          . sort ( ( _a ,  _b )  =>  { 
199201            const  [ ,  a ]  =  _a  as  [ string ,  NavItem ] ; 
200202            const  [ ,  b ]  =  _b  as  [ string ,  NavItem ] ; 
Original file line number Diff line number Diff line change @@ -203,4 +203,5 @@ export interface NavItem {
203203  status ?: Status ; 
204204  children ?: NavJSON ; 
205205  expanded ?: boolean ; 
206+   hideFromNav ?: boolean ; 
206207} 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments