Skip to content

Commit 31e1f7d

Browse files
authored
refactor(docs): upgrade versions and overhaul structure and content (CopilotKit#2120)
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
1 parent 9d8a197 commit 31e1f7d

260 files changed

Lines changed: 6559 additions & 7167 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit-props.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export interface CopilotKitProps {
8888
* }
8989
* ```
9090
*
91-
* **Note**: The `authorization` property is automatically forwarded to LangGraph agents. See the [LangGraph Agent Authentication Guide](/coagents/shared-guides/langgraph-platform-authentication) for details.
91+
* **Note**: The `authorization` property is automatically forwarded to LangGraph agents. See the [LangGraph Agent Authentication Guide](/coagents/shared/guides/langgraph-platform-authentication) for details.
9292
*/
9393
properties?: Record<string, any>;
9494

docs/app/(home)/[[...slug]]/page.tsx

Lines changed: 70 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { notFound } from "next/navigation";
1010
import defaultMdxComponents from "fumadocs-ui/mdx";
1111
import { Badge } from "@/components/ui/badge";
1212
import { CloudIcon } from "lucide-react";
13-
import { getImageMeta } from "fumadocs-ui/og";
14-
1513
import { Tabs, Tab } from "@/components/react/tabs";
1614
import { Steps, Step } from "fumadocs-ui/components/steps";
1715
import { TypeTable } from "fumadocs-ui/components/type-table";
@@ -25,6 +23,7 @@ import { InsecurePasswordProtected } from "@/components/react/insecure-password-
2523
import { LinkToCopilotCloud } from "@/components/react/link-to-copilot-cloud";
2624
import { Accordions, Accordion } from "fumadocs-ui/components/accordion";
2725
import { NavigationLink } from "@/components/react/subdocs-menu";
26+
import { getSnippetTOCForPage } from "@/lib/snippet-toc";
2827

2928
/**
3029
* TODO: This should be dynamic, but it's not working.
@@ -68,59 +67,88 @@ const mdxComponents = {
6867
export default async function Page({
6968
params,
7069
}: {
71-
params: { slug?: string[] };
70+
params: Promise<{ slug?: string[] }>;
7271
}) {
73-
const page = source.getPage(params.slug);
72+
const resolvedParams = await params;
73+
const page = source.getPage(resolvedParams.slug);
7474
if (!page) notFound();
7575
const MDX = page.data.body;
7676
const cloudOnly = cloudOnlyFeatures.includes(page.data.title);
77+
7778
// Consider a page "Premium" if its slug path contains a "premium" segment OR title matches known premium features OR frontmatter premium flag
7879
const bySlugPremium = Array.isArray(page.slugs) ? page.slugs.includes("premium") : false;
7980
const byTitlePremium = premiumFeatureTitles.includes(page.data.title || "");
8081
const byFrontmatterPremium = Boolean((page as any).data?.premium);
8182
const isPremium = bySlugPremium || byTitlePremium || byFrontmatterPremium;
8283
// Compute premium overview href based on current section (first slug segment)
8384
const baseSegment = Array.isArray(page.slugs) && page.slugs.length ? `/${page.slugs[0]}` : "/";
84-
const premiumOverviewHref = baseSegment === "/" ? "/(root)/premium/overview" : `${baseSegment}/premium/overview`;
85-
85+
const premiumOverviewHref =
86+
baseSegment === "/" ? "/premium/overview" : `${baseSegment}/premium/overview`;
87+
88+
// Check if the page should hide the header or TOC
89+
const hideHeader = (page.data as any).hideHeader || false;
90+
const hideTOC = (page.data as any).hideTOC || false;
91+
92+
// Get TOC from imported snippets and merge with page TOC (only if TOC is not hidden)
93+
// Use try-catch to handle build-time issues gracefully
94+
let snippetTOC: any[] = [];
95+
if (!hideTOC) {
96+
try {
97+
snippetTOC = await getSnippetTOCForPage(resolvedParams.slug);
98+
} catch (error) {
99+
console.warn('Failed to load snippet TOC:', error);
100+
snippetTOC = [];
101+
}
102+
}
103+
const combinedTOC = hideTOC ? [] : [...(page.data.toc || []), ...snippetTOC];
104+
86105
return (
87106
<DocsPage
88-
toc={[]}
107+
toc={combinedTOC}
89108
full={page.data.full}
109+
tableOfContent={{
110+
style:"clerk",
111+
}}
90112
>
91-
<div className="flex items-center gap-3">
92-
<DocsTitle className="flex items-center">
93-
{page.data.title}
94-
{cloudOnly && (
95-
<Badge
96-
variant="secondary"
97-
className="ml-3 mt-1 inline-flex items-center gap-1.5 py-1.5 px-3 bg-indigo-600/90 text-white hover:bg-indigo-600 border-0 rounded-md transition-colors"
98-
>
99-
<CloudIcon className="w-3 h-3" />
100-
<span className="text-xs">Cloud Only</span>
101-
</Badge>
102-
)}
103-
{isPremium && (
104-
<a href={premiumOverviewHref} className="ml-3 mt-1">
105-
<Badge
106-
variant="secondary"
107-
className="inline-flex items-center gap-2 py-2 px-3.5 bg-indigo-100 text-indigo-700 dark:bg-indigo-900/40 dark:text-indigo-200 hover:bg-indigo-200 border-0 rounded-md transition-colors"
108-
>
109-
<img
110-
src="https://cdn.copilotkit.ai/docs/copilotkit/images/copilotkit-logo.svg"
111-
alt="CopilotKit"
112-
className="w-5 h-5"
113-
/>
114-
<span className="text-sm font-semibold tracking-tight">Premium</span>
115-
</Badge>
116-
</a>
117-
)}
118-
</DocsTitle>
113+
<div className={hideHeader ? "" : "min-h-screen"}>
114+
{!hideHeader && (
115+
<>
116+
<div className="flex items-center gap-3">
117+
<DocsTitle className="flex items-center mb-2">
118+
{page.data.title}
119+
{cloudOnly && (
120+
<Badge
121+
variant="secondary"
122+
className="ml-3 mt-1 inline-flex items-center gap-1.5 py-1.5 px-3 bg-indigo-600/90 text-white hover:bg-indigo-600 border-0 rounded-md transition-colors"
123+
>
124+
<CloudIcon className="w-3 h-3" />
125+
<span className="text-xs">Cloud Only</span>
126+
</Badge>
127+
)}
128+
{isPremium && (
129+
<a href={premiumOverviewHref} className="ml-3">
130+
<Badge
131+
variant="secondary"
132+
className="inline-flex items-center gap-2 py-2 px-3.5 bg-indigo-100 text-indigo-700 dark:bg-indigo-900/40 dark:text-indigo-200 hover:bg-indigo-200 border-0 rounded-md transition-colors"
133+
>
134+
<img
135+
src="https://cdn.copilotkit.ai/docs/copilotkit/icons/copilotkit-color.svg"
136+
alt="CopilotKit"
137+
className="w-4 h-4"
138+
/>
139+
<span className="text-sm font-semibold tracking-tight">Premium</span>
140+
</Badge>
141+
</a>
142+
)}
143+
</DocsTitle>
144+
</div>
145+
<DocsDescription>{page.data.description}</DocsDescription>
146+
</>
147+
)}
148+
<DocsBody>
149+
<MDX components={mdxComponents} />
150+
</DocsBody>
119151
</div>
120-
<DocsDescription>{page.data.description}</DocsDescription>
121-
<DocsBody>
122-
<MDX components={mdxComponents} renderSmth={() => <div>test</div>} />
123-
</DocsBody>
124152
</DocsPage>
125153
);
126154
}
@@ -129,21 +157,13 @@ export async function generateStaticParams() {
129157
return source.generateParams();
130158
}
131159

132-
export function generateMetadata({ params }: { params: { slug?: string[] } }) {
133-
const page = source.getPage(params.slug);
160+
export async function generateMetadata({ params }: { params: Promise<{ slug?: string[] }> }) {
161+
const resolvedParams = await params;
162+
const page = source.getPage(resolvedParams.slug);
134163
if (!page) notFound();
135164

136-
const image = getImageMeta("og", page.slugs);
137-
138165
return {
139166
title: page.data.title,
140167
description: page.data.description,
141-
openGraph: {
142-
images: image,
143-
},
144-
twitter: {
145-
images: image,
146-
card: "summary_large_image",
147-
},
148168
} satisfies Metadata;
149169
}

docs/app/(home)/layout.tsx

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { DocsLayout } from "fumadocs-ui/layout";
1+
import { DocsLayout } from "fumadocs-ui/layouts/docs";
22
import type { ReactNode } from "react";
33
import { baseOptions } from "../layout.config";
44
import { source } from "@/app/source";
55
import { SubdocsMenu } from "@/components/react/subdocs-menu";
6-
import { TerminalIcon, RocketIcon, BoxesIcon } from "lucide-react";
6+
import { TerminalIcon, RocketIcon, CloudIcon } from "lucide-react";
77
import { SiCrewai } from "@icons-pack/react-simple-icons";
8-
import { TopBar } from "@/components/layout/top-bar";
98
import { SiLangchain } from "react-icons/si";
109
import {
1110
AG2Icon,
@@ -18,12 +17,11 @@ import {
1817
export default function Layout({ children }: { children: ReactNode }) {
1918
return (
2019
<>
21-
<TopBar />
2220
<DocsLayout
2321
tree={source.pageTree}
24-
{...baseOptions}
22+
searchToggle={{ enabled: true }}
2523
sidebar={{
26-
hideSearch: true,
24+
tabs: false, // Disable default tab picker to rely on root folders
2725
banner: (
2826
<SubdocsMenu
2927
options={[
@@ -37,18 +35,7 @@ export default function Layout({ children }: { children: ReactNode }) {
3735
selectedStyle: "ring-blue-500/70 ring-2 rounded-sm",
3836
},
3937
{
40-
title: "API Reference",
41-
description: "API Reference",
42-
url: "/reference",
43-
icon: <TerminalIcon className="w-4 h-4" />,
44-
bgGradient:
45-
"bg-gradient-to-b from-teal-700 to-teal-400 text-teal-100",
46-
selectedStyle: "ring-teal-500/70 ring-2 rounded-sm",
47-
},
48-
{ type: "separator" },
49-
{ type: "label", text: "Choose Agent Integration" },
50-
{
51-
title: "LLM or Agent Framework",
38+
title: "Integrations",
5239
options: [
5340
{
5441
title: "Direct to LLM",
@@ -153,19 +140,31 @@ export default function Layout({ children }: { children: ReactNode }) {
153140
},
154141
],
155142
},
156-
// {
157-
// title: "Chat with our docs",
158-
// description: "Chat with our docs",
159-
// url: "https://entelligence.ai/CopilotKit&CopilotKit",
160-
// icon: <CircleArrowOutUpRight className="w-4 h-4" />,
161-
// bgGradient:
162-
// "bg-gradient-to-b from-purple-700 to-purple-400 text-purple-100",
163-
// selectedBorder: "ring-teal-500/70",
164-
// },
143+
{
144+
title: "Copilot Cloud",
145+
description: "Copilot Cloud",
146+
href: "https://cloud.copilotkit.ai",
147+
url: "https://cloud.copilotkit.ai",
148+
icon: <CloudIcon className="w-4 h-4" />,
149+
bgGradient:
150+
"bg-gradient-to-b from-blue-700 to-blue-400 text-blue-100",
151+
selectedStyle: "ring-blue-500/70 ring-2 rounded-sm",
152+
},
153+
{
154+
title: "API Reference",
155+
description: "API Reference",
156+
url: "/reference",
157+
icon: <TerminalIcon className="w-4 h-4" />,
158+
bgGradient:
159+
"bg-gradient-to-b from-teal-700 to-teal-400 text-teal-100",
160+
selectedStyle: "ring-teal-500/70 ring-2 rounded-sm",
161+
},
165162
]}
163+
166164
/>
167165
),
168166
}}
167+
{...baseOptions}
169168
>
170169
{children}
171170
</DocsLayout>

0 commit comments

Comments
 (0)