()
| 25 | } |
| 26 | |
| 27 | export function Nav() { |
| 28 | let {pages, currentPage} = useRouter(); |
| 29 | let [maskSize, setMaskSize] = useState(0); |
| 30 | let displayPage = usePendingPage(); |
| 31 | |
| 32 | if (currentPage.exports?.hideNav) { |
| 33 | return null; |
| 34 | } |
| 35 | |
| 36 | let currentLibrary = getLibraryFromPage(displayPage); |
| 37 | let sections = new Map<string, SectionValue>(); |
| 38 | for (let page of pages) { |
| 39 | if (page.exports?.hideNav || page.exports?.omitFromNav) { |
| 40 | continue; |
| 41 | } |
| 42 | |
| 43 | let library = getLibraryFromPage(page); |
| 44 | |
| 45 | if (currentLibrary === 'react-spectrum' && library !== currentLibrary) { |
| 46 | continue; |
| 47 | } |
| 48 | |
| 49 | // 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 |
| 50 | if (currentLibrary === 'react-aria' && library === 'react-spectrum') { |
| 51 | continue; |
| 52 | } |
| 53 | |
| 54 | let section = page.exports?.section ?? 'Components'; |
| 55 | let group = page.exports?.group ?? undefined; |
| 56 | if (section === '' || page.exports?.isSubpage) { |
| 57 | continue; |
| 58 | } |
| 59 | |
| 60 | if (group && section) { |
| 61 | let value = sections.get(group); |
| 62 | let groupMap: Map<string, Page[]>; |
| 63 | if (value instanceof Map) { |
| 64 | groupMap = value; |
| 65 | } else { |
| 66 | groupMap = new Map<string, Page[]>(); |
| 67 | } |
| 68 | let groupPages = groupMap.get(section) ?? []; |
| 69 | groupPages.push(page); |
| 70 | groupMap.set(section, groupPages); |
| 71 | sections.set(group, groupMap); |
| 72 | } else if (section) { |
| 73 | let value = sections.get(section); |
| 74 | let sectionPages = Array.isArray(value) ? value : []; |
| 75 | sectionPages.push(page); |
| 76 | sections.set(section, sectionPages); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | let sortedSections = [...sections].sort((a, b) => { |
| 81 | if (a[0] === 'Overview') { |
| 82 | return -1; |
| 83 | } |
| 84 | if (b[0] === 'Overview') { |
nothing calls this directly
no test coverage detected