Skip to content

Commit ac8dffb

Browse files
committed
add descriptions to menu and remove from card list
1 parent d4e1020 commit ac8dffb

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

packages/dev/s2-docs/src/CardList.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ export function CardList({selectedLibrary, pages}: CardListProps) {
6060

6161
const name = page.url.replace(/^\//, '').replace(/\.html$/, '');
6262
const title = page.tableOfContents?.[0]?.title || name;
63-
64-
const component = {
63+
64+
const component: IExampleItem = {
6565
id: name,
6666
name: title,
67-
description: `${title} documentation`,
6867
href: page.url
6968
};
7069

@@ -135,7 +134,6 @@ export function CardList({selectedLibrary, pages}: CardListProps) {
135134
</CardPreview>
136135
<Content>
137136
<Text slot="title">{item.name}</Text>
138-
{item.description && <Text slot="description">{item.description}</Text>}
139137
</Content>
140138
</Card>
141139
</Link>

packages/dev/s2-docs/src/SearchMenu.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import {fontRelative, style} from '@react-spectrum/s2/style' with { type: 'macro
77
import {InternationalizedLogo} from './icons/InternationalizedLogo';
88
import {Page} from '@parcel/rsc';
99
import React, {CSSProperties, useEffect, useMemo, useRef, useState} from 'react';
10+
// @ts-ignore
11+
import reactAriaDocs from 'docs:react-aria-components';
1012
import {ReactAriaLogo} from './icons/ReactAriaLogo';
13+
// @ts-ignore
14+
import reactSpectrumDocs from 'docs:@react-spectrum/s2';
1115
import Search from '@react-spectrum/s2/icons/Search';
1216
import SearchResultsMenu from './SearchResultsMenu';
1317
import {Tab, TabList, TabPanel, Tabs} from './Tabs';
@@ -194,13 +198,30 @@ export default function SearchMenu(props: SearchMenuProps) {
194198
.map(page => {
195199
const name = page.url.replace(/^\//, '').replace(/\.html$/, '');
196200
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+
198219
return {
199220
id: name,
200221
name: title,
201222
category: 'Components', // TODO
202223
href: page.url,
203-
description: `${title} documentation` // TODO
224+
description: description
204225
};
205226
});
206227

0 commit comments

Comments
 (0)