-
Notifications
You must be signed in to change notification settings - Fork 0
/
Root.tsx
29 lines (27 loc) · 943 Bytes
/
Root.tsx
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
import { DocPage } from '../../components/DocPage'
import { Error } from '../../components/Error'
import { Layout } from '../../components/Layout'
import { Menu, useGetTocQuery } from '../../features/toc'
import { useCurrentPageUrl } from '../../hooks/useCurrentPageUrl'
import tocUrl from '/toc.json?url'
export function Root() {
const query = useGetTocQuery(tocUrl)
const currentUrl = useCurrentPageUrl()
return (
<Layout>
<Layout.Sidebar>
{!query.isError && (
<Menu
activeUrl={currentUrl}
toc={query.data}
isLoading={query.isLoading}
/>
)}
</Layout.Sidebar>
<Layout.Main>
{query.isSuccess && (<DocPage toc={query.data} />)}
{query.isError && <Error />}
</Layout.Main>
</Layout>
)
}