forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.tsx
More file actions
136 lines (128 loc) · 5.08 KB
/
Copy pathpage.tsx
File metadata and controls
136 lines (128 loc) · 5.08 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import Link from "next/link";
import { DocsPage } from "fumadocs-ui/page";
import { ShellDocsLayout } from "@/components/shell-docs-layout";
import { ReferenceVersionSelector } from "@/components/reference-version-selector";
import {
REFERENCE_CATEGORIES,
REFERENCE_VERSIONS,
buildReferencePageTree,
loadReferenceVersionItems,
referenceVersionHref,
} from "@/lib/reference-items";
import type { ReferenceCategory, ReferenceItem } from "@/lib/reference-items";
function displayTitle(item: ReferenceItem): string {
if (item.category === "Components") return `<${item.title} />`;
if (item.category === "Hooks") return `${item.title}()`;
return item.title;
}
function categoryItems(
items: ReferenceItem[],
category: ReferenceCategory,
): ReferenceItem[] {
return items.filter((item) => item.category === category);
}
// SDK *families* shown as cards at the top of the Overview. This is not a
// 1:1 mapping of REFERENCE_VERSIONS — React v1 is a legacy version reachable
// via the sidebar picker, not its own card. The body below this chooser lists
// the React reference (the default landing); the sidebar picker switches SDKs.
const SDK_CHOICES: { name: string; description: string; href: string }[] = [
{
name: "React",
description:
"Hooks and components for building CopilotKit into a React app.",
href: referenceVersionHref("v2"),
},
{
name: "Core (TypeScript)",
description:
"The framework-agnostic @copilotkit/core client — runs anywhere JavaScript runs.",
href: referenceVersionHref("core"),
},
];
export default function ReferencePage() {
const activeVersion = "v2";
const allItems = loadReferenceVersionItems(activeVersion);
const pageTree = buildReferencePageTree(activeVersion);
const intro =
"Reference documentation for the CopilotKit SDKs. Pick the SDK you're building with, then browse its components, hooks, classes, and types.";
const versionOptions = REFERENCE_VERSIONS.map((version) => ({
version,
href: referenceVersionHref(version),
}));
return (
<ShellDocsLayout
tree={pageTree}
banner={
<ReferenceVersionSelector
activeVersion={activeVersion}
options={versionOptions}
/>
}
>
<DocsPage
toc={[]}
tableOfContent={{ enabled: false }}
tableOfContentPopover={{ enabled: false }}
breadcrumb={{ enabled: false }}
footer={{ enabled: false }}
>
<div className="docs-inner-content mx-auto max-w-4xl px-6 py-12">
<h1 className="text-2xl font-bold text-[var(--text)] mb-2">
Overview
</h1>
<p className="text-[var(--text-muted)] text-sm mb-10">{intro}</p>
<section className="mb-12">
<h2 className="text-lg font-semibold text-[var(--text)] mb-4">
Choose your SDK
</h2>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
{SDK_CHOICES.map((sdk) => (
<Link
key={sdk.name}
href={sdk.href}
className="block rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] p-4 hover:bg-[var(--bg-elevated)] transition-colors"
>
<div className="font-mono text-sm font-semibold text-[var(--accent)]">
{sdk.name}
</div>
<div className="text-xs text-[var(--text-muted)] mt-1">
{sdk.description}
</div>
</Link>
))}
</div>
</section>
{REFERENCE_CATEGORIES.map((category) => {
const items = categoryItems(allItems, category);
if (items.length === 0) return null;
return (
<section key={category} className="mb-10 last:mb-0">
<h2 className="text-lg font-semibold text-[var(--text)] mb-4">
{category === "Components" ? "UI Components" : category}
</h2>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
{items.map((item) => (
<Link
key={item.slug}
href={item.url}
className="shell-docs-radius-surface block min-w-0 border border-[var(--border)] bg-[var(--bg-surface)] p-4 shadow-[var(--shadow-control)] transition-colors hover:border-[var(--accent)] hover:bg-[var(--bg-elevated)]"
>
<div className="min-w-0 break-words font-mono text-sm font-semibold text-[var(--accent)] [overflow-wrap:anywhere]">
{displayTitle(item)}
</div>
{item.description && (
<div className="mt-1 min-w-0 break-words text-xs text-[var(--text-muted)] [overflow-wrap:anywhere]">
{item.description}
</div>
)}
</Link>
))}
</div>
</section>
);
})}
</div>
</DocsPage>
</ShellDocsLayout>
);
}