forked from nodejs/doc-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.jsx
More file actions
48 lines (44 loc) · 1.29 KB
/
index.jsx
File metadata and controls
48 lines (44 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import Select from '@node-core/ui-components/Common/Select';
import SideBar from '@node-core/ui-components/Containers/Sidebar';
import styles from './index.module.css';
/**
* @typedef {Object} SideBarProps
* @property {string} pathname - The current document
* @property {Array<string>} versions - Available documentation versions
* @property {string} currentVersion - Currently selected version
* @property {Array<[string, string]>} docPages - [Title, URL] pairs
*/
/**
* Redirect to a URL
* @param {string} url URL
*/
const redirect = url => (window.location.href = url);
/**
* Sidebar component for MDX documentation with version selection and page navigation
* @param {SideBarProps} props - Component props
*/
export default ({ versions, pathname, currentVersion, docPages }) => (
<SideBar
pathname={pathname}
groups={[
{
groupName: 'API Documentation',
items: docPages.map(([label, link]) => ({ label, link })),
},
]}
onSelect={redirect}
as={props => <a {...props} rel="prefetch" />}
title="Navigation"
>
<div>
<Select
label="Node.js version"
values={versions}
inline={true}
className={styles.select}
placeholder={currentVersion}
onChange={redirect}
/>
</div>
</SideBar>
);