This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +28
-7
lines changed Expand file tree Collapse file tree 1 file changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -16,19 +16,40 @@ const searchPluginConfig = {
16
16
fields {
17
17
path
18
18
}
19
+ tableOfContents
19
20
}
20
21
}
21
22
}
22
23
` ,
23
24
index : [ "title" ] ,
24
25
normalizer : ( { data } ) =>
25
- data . allMdx . nodes . map ( ( node ) => ( {
26
- id : node . id ,
27
- title : node . frontmatter . title ,
28
- description : node . frontmatter . description ,
29
- url : node . fields . path ,
30
- isExternal : false ,
31
- } ) ) ,
26
+ data . allMdx . nodes . flatMap ( ( node ) => {
27
+ // return at least the main page ("node")
28
+ const returnVal = [
29
+ {
30
+ id : node . id ,
31
+ title : node . frontmatter . title ,
32
+ description : node . frontmatter . description ,
33
+ url : node . fields . path ,
34
+ isExternal : false ,
35
+ toc : node . tableOfContents ,
36
+ } ,
37
+ ] ;
38
+
39
+ // add the headers too if they're in ToC
40
+ if ( node . tableOfContents . items != null ) {
41
+ node . tableOfContents . items . map ( ( header ) =>
42
+ returnVal . push ( {
43
+ id : node . id . concat ( header . url ) ,
44
+ title : node . frontmatter . title . concat ( " - " , header . title ) ,
45
+ url : node . fields . path . concat ( header . url ) ,
46
+ isExternal : false ,
47
+ } )
48
+ ) ;
49
+ }
50
+
51
+ return returnVal ;
52
+ } ) ,
32
53
} ,
33
54
} ;
34
55
You can’t perform that action at this time.
0 commit comments