-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocumentation-layout.tsx
More file actions
99 lines (92 loc) · 2.9 KB
/
documentation-layout.tsx
File metadata and controls
99 lines (92 loc) · 2.9 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { DocsSidebar } from "./docs-sidebar";
import { TableOfContents } from "./table-of-contents";
import { Search } from "./search";
import { DocPagination } from "./doc-pagination";
import { ReactDocsConfig } from "./config";
import { DocsThemeProvider } from "./theme-context";
import { getDocsSidebar } from "./util";
interface Props {
config: ReactDocsConfig;
navigation: any;
children: React.ReactNode;
currentPath: string;
headings: {
id: string;
text: string;
level: number;
}[];
}
export function DocumentationLayout({
config,
navigation,
children,
currentPath,
headings,
}: Props) {
// Get docs configuration for theming
const { config: docsConfig } = getDocsSidebar(config);
// Find current page and get prev/next
const allPages = navigation.flatMap((section: any) => section.pages);
const currentPageIndex = allPages.findIndex(
(page: any) => config.basePath + `/${page.slug}` === currentPath
);
const prevPage =
currentPageIndex > 0 ? allPages[currentPageIndex - 1] : undefined;
const nextPage =
currentPageIndex < allPages.length - 1
? allPages[currentPageIndex + 1]
: undefined;
return (
<DocsThemeProvider config={docsConfig}>
<div className="max-w-screen-xl mx-auto px-4">
<div className="flex gap-8">
{/* Left Sidebar */}
<div className="w-64 flex-shrink-0 hidden md:block">
<div className="sticky top-0">
<div className="py-4">
<DocsSidebar
config={config}
navigation={navigation}
currentPath={currentPath}
/>
</div>
</div>
</div>
<div className="flex-1 min-w-0">
{/* Sticky Search Container */}
<div className="sticky top-0 z-50 bg-gray-900/95 border-b border-gray-800">
<div className="py-4">
<div className="flex items-center gap-1">
<div className="md:hidden">
<DocsSidebar
config={config}
navigation={navigation}
currentPath={currentPath}
/>
</div>
<div className="flex-1 md:max-w-2xl md:mx-auto">
<Search config={config} />
</div>
</div>
</div>
</div>
<main className="py-8 max-w-2xl mx-auto">
<div className="relative z-0">
{children}
<DocPagination config={config} prev={prevPage} next={nextPage} />
</div>
</main>
</div>
{/* Right Sidebar */}
<div className="w-64 flex-shrink-0 hidden lg:block">
<div className="sticky top-0">
<div className="py-4">
<TableOfContents headings={headings} />
</div>
</div>
</div>
</div>
</div>
</DocsThemeProvider>
);
}