-
Notifications
You must be signed in to change notification settings - Fork 711
Expand file tree
/
Copy pathindex.js
More file actions
74 lines (69 loc) · 2.25 KB
/
index.js
File metadata and controls
74 lines (69 loc) · 2.25 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import Link from '@docusaurus/Link';
import { useThemeConfig } from '@docusaurus/theme-common';
import {
splitNavbarItems,
useNavbarMobileSidebar,
} from '@docusaurus/theme-common/internal';
import NavbarLogo from '@theme/Navbar/Logo';
import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
import NavbarSearch from '@theme/Navbar/Search';
import NavbarItem from '@theme/NavbarItem';
import SearchBar from '@theme/SearchBar';
import clsx from 'clsx';
import React from 'react';
import styles from './styles.module.css';
function useNavbarItems() {
return useThemeConfig().navbar.items;
}
function NavbarItems({ items, className }) {
return (
<div className={clsx(styles.navbarItems, className)}>
{items.map((item, i) => (
<NavbarItem {...item} key={i} />
))}
</div>
);
}
function NavbarContentLayout({ left, right }) {
return (
<div className="navbar__inner">
<div className="navbar__items">{left}</div>
<div className="navbar__items navbar__items--right">{right}</div>
</div>
);
}
export default function NavbarContent() {
const mobileSidebar = useNavbarMobileSidebar();
const items = useNavbarItems();
const [leftItems, rightItems] = splitNavbarItems(items);
const searchBarItem = items.find((item) => item.type === 'search');
return (
<NavbarContentLayout
left={
<>
<NavbarLogo />
<NavbarItems items={leftItems} />
</>
}
right={
<>
{rightItems?.length > 0 && (
<NavbarItems items={rightItems} />
)}
{!searchBarItem && (
<NavbarSearch>
<SearchBar />
</NavbarSearch>
)}
<Link
className={styles.getStartedButton}
to="/docs/quick-start"
>
Get started
</Link>
{!mobileSidebar.disabled && <NavbarMobileSidebarToggle />}
</>
}
/>
);
}