@@ -7,7 +7,11 @@ import {fontRelative, style} from '@react-spectrum/s2/style' with { type: 'macro
7
7
import { InternationalizedLogo } from './icons/InternationalizedLogo' ;
8
8
import { Page } from '@parcel/rsc' ;
9
9
import React , { CSSProperties , useEffect , useMemo , useRef , useState } from 'react' ;
10
+ // @ts -ignore
11
+ import reactAriaDocs from 'docs:react-aria-components' ;
10
12
import { ReactAriaLogo } from './icons/ReactAriaLogo' ;
13
+ // @ts -ignore
14
+ import reactSpectrumDocs from 'docs:@react-spectrum/s2' ;
11
15
import Search from '@react-spectrum/s2/icons/Search' ;
12
16
import SearchResultsMenu from './SearchResultsMenu' ;
13
17
import { Tab , TabList , TabPanel , Tabs } from './Tabs' ;
@@ -194,13 +198,30 @@ export default function SearchMenu(props: SearchMenuProps) {
194
198
. map ( page => {
195
199
const name = page . url . replace ( / ^ \/ / , '' ) . replace ( / \. h t m l $ / , '' ) ;
196
200
const title = page . tableOfContents ?. [ 0 ] ?. title || name ;
197
-
201
+ let lib : 'react-spectrum' | 'react-aria' | 'internationalized' = 'react-spectrum' ;
202
+ if ( page . url . includes ( 'react-aria' ) ) {
203
+ lib = 'react-aria' ;
204
+ } else if ( page . url . includes ( 'internationalized' ) ) {
205
+ lib = 'internationalized' ;
206
+ }
207
+
208
+ // get description from docs metadata
209
+ const componentKey = title . replace ( / \s + / g, '' ) ;
210
+ let description : string | undefined = undefined ;
211
+ if ( lib === 'react-aria' ) {
212
+ // @ts -ignore
213
+ description = ( reactAriaDocs as any ) ?. exports ?. [ componentKey ] ?. description ;
214
+ } else if ( lib === 'react-spectrum' ) {
215
+ // @ts -ignore
216
+ description = ( reactSpectrumDocs as any ) ?. exports ?. [ componentKey ] ?. description ;
217
+ }
218
+
198
219
return {
199
220
id : name ,
200
221
name : title ,
201
222
category : 'Components' , // TODO
202
223
href : page . url ,
203
- description : ` ${ title } documentation` // TODO
224
+ description : description
204
225
} ;
205
226
} ) ;
206
227
0 commit comments