-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathindex.jsx
More file actions
52 lines (45 loc) · 1.57 KB
/
index.jsx
File metadata and controls
52 lines (45 loc) · 1.57 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
49
50
51
52
import ThemeToggle from '@node-core/ui-components/Common/ThemeToggle';
import NavBar from '@node-core/ui-components/Containers/NavBar';
import styles from '@node-core/ui-components/Containers/NavBar/index.module.css';
import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub';
import SearchBox from '@node-core/doc-kit/src/generators/web/ui/components/SearchBox';
import { useTheme } from '@node-core/doc-kit/src/generators/web/ui/hooks/useTheme.mjs';
import { useEffect, useState } from 'preact/hooks';
import { useIntl } from 'react-intl';
import localizeLink from '../../util/link';
import { navigation } from '../../site.json' with { type: 'json' };
import Logo from '#theme/Logo';
/**
* NavBar component that displays the headings, search, etc.
*/
export default ({ metadata }) => {
const [themePreference, setThemePreference] = useTheme();
const [navigationItems, setNavigationItems] = useState(navigation);
const { locale } = useIntl();
useEffect(() => {
const items = navigation.map(item => ({
...item,
link: localizeLink(item.link, locale),
}));
setNavigationItems(items);
}, [locale]);
return (
<NavBar
Logo={Logo}
sidebarItemTogglerAriaLabel="Toggle navigation menu"
navItems={navigationItems}
>
<SearchBox pathname={metadata.path} />
<ThemeToggle
onChange={setThemePreference}
currentTheme={themePreference}
/>
<a
href={`https://github.com/nodejs/learn`}
className={styles.ghIconWrapper}
>
<GitHubIcon />
</a>
</NavBar>
);
};