()
| 16 | } |
| 17 | |
| 18 | export function Nav() { |
| 19 | let {pages, currentPage} = useRouter(); |
| 20 | let [maskSize, setMaskSize] = useState(0); |
| 21 | let displayPage = usePendingPage(); |
| 22 | |
| 23 | if (currentPage.exports?.hideNav) { |
| 24 | return null; |
| 25 | } |
| 26 | |
| 27 | let currentLibrary = getLibraryFromPage(displayPage); |
| 28 | let sections = new Map<string, SectionValue>(); |
| 29 | let sectionLibrary = new Map(); |
| 30 | for (let page of pages) { |
| 31 | if (page.exports?.hideNav || page.exports?.omitFromNav) { |
| 32 | continue; |
| 33 | } |
| 34 | |
| 35 | let library = getLibraryFromPage(page); |
| 36 | |
| 37 | if (currentLibrary === 'react-spectrum' && library !== currentLibrary) { |
| 38 | continue; |
| 39 | } |
| 40 | |
| 41 | // If the current library is React Aria, we only want to skip pages in React Spectrum so that include Internationalized pages in the side nav |
| 42 | if (currentLibrary === 'react-aria' && library === 'react-spectrum') { |
| 43 | continue; |
| 44 | } |
| 45 | |
| 46 | let section = page.exports?.section ?? 'Components'; |
| 47 | let group = page.exports?.group ?? undefined; |
| 48 | if (section === '' || page.exports?.isSubpage) { |
| 49 | continue; |
| 50 | } |
| 51 | |
| 52 | if (group && section) { |
| 53 | let value = sections.get(group); |
| 54 | let groupMap: Map<string, Page[]>; |
| 55 | if (value instanceof Map) { |
| 56 | groupMap = value; |
| 57 | } else { |
| 58 | groupMap = new Map<string, Page[]>(); |
| 59 | } |
| 60 | let groupPages = groupMap.get(section) ?? []; |
| 61 | groupPages.push(page); |
| 62 | groupMap.set(section, groupPages); |
| 63 | sections.set(group, groupMap); |
| 64 | } else if (section) { |
| 65 | let value = sections.get(section); |
| 66 | let sectionPages = Array.isArray(value) ? value : []; |
| 67 | sectionPages.push(page); |
| 68 | sections.set(section, sectionPages); |
| 69 | } |
| 70 | |
| 71 | sectionLibrary.set(section, library); |
| 72 | } |
| 73 | |
| 74 | let sortedSections = [...sections].sort((a, b) => { |
| 75 | if (a[0] === 'Overview') { |
nothing calls this directly
no test coverage detected