forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayout.tsx
More file actions
163 lines (155 loc) · 5.3 KB
/
Copy pathlayout.tsx
File metadata and controls
163 lines (155 loc) · 5.3 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import type { Metadata } from "next";
import { Plus_Jakarta_Sans, Spline_Sans_Mono } from "next/font/google";
import Script from "next/script";
import { Suspense } from "react";
import { AnalyticsClient } from "@/components/analytics-client";
import { BrandNav } from "@/components/brand-nav";
import { FrameworkProvider } from "@/components/framework-provider";
import { PostHogProvider } from "@/lib/providers/posthog-provider";
import { ScarfPixel } from "@/lib/providers/scarf-pixel";
import { getIntegrations } from "@/lib/registry";
import "./globals.css";
// Top-level route segments in src/app/ that must not be mistaken for
// framework slugs by FrameworkProvider.urlFramework. If an integration
// registry entry ever ships a slug colliding with one of these, the
// framework URL-resolver would otherwise hijack the route.
export const RESERVED_ROUTE_SLUGS = [
"docs",
"ag-ui",
"reference",
"api",
] as const;
const plusJakartaSans = Plus_Jakarta_Sans({
subsets: ["latin"],
variable: "--font-prose",
display: "swap",
});
const splineSansMono = Spline_Sans_Mono({
subsets: ["latin"],
variable: "--font-mono",
display: "swap",
});
export const metadata: Metadata = {
title: "CopilotKit Docs",
description: "Docs, live demos, and integrations for CopilotKit",
};
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
// FrameworkProvider needs the set of known framework slugs so it can
// detect URL-scoped framework views. The framework *selector* now
// lives inside the docs sidebar, not in the top bar, so its own
// options are wired up in the docs page-level server components.
//
// Guard against registry slugs that would collide with top-level
// route segments under src/app/ (see RESERVED_ROUTE_SLUGS). Without
// this filter, a registry entry named e.g. "reference" would cause
// FrameworkProvider.urlFramework to treat /reference as a framework
// scope rather than the reference docs route.
const reserved = new Set<string>(RESERVED_ROUTE_SLUGS);
const knownFrameworks = getIntegrations()
.map((i) => i.slug)
.filter((slug) => {
if (reserved.has(slug)) {
// Always log — a registry integration slug colliding with a
// reserved top-level route is a hard wiring bug that production
// operators need to see in logs, not a dev-only warning.
// eslint-disable-next-line no-console
console.error(
`[layout] integration slug "${slug}" collides with a reserved top-level route and was dropped from knownFrameworks. Rename the integration slug or update RESERVED_ROUTE_SLUGS.`,
);
return false;
}
return true;
});
// Distinguish "unset" from "empty" for the commit-SHA overlay.
// Docker ARG scope bugs can surface as an empty string rather than
// undefined; showing "dev" in that case is misleading. See the
// Dockerfile fix for the root cause.
const rawSha = process.env.NEXT_PUBLIC_COMMIT_SHA;
const commitLabel =
rawSha === undefined
? "dev"
: rawSha === ""
? "unknown"
: rawSha.slice(0, 7);
const REO_KEY = process.env.NEXT_PUBLIC_REO_KEY;
const REB2B_KEY = process.env.NEXT_PUBLIC_REB2B_KEY;
return (
<html
lang="en"
className={`${plusJakartaSans.variable} ${splineSansMono.variable}`}
>
<head>
{REO_KEY ? (
<Script
id="reo-init-script"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
!function(){
var e, t, n;
e = ${JSON.stringify(REO_KEY)};
t = function() {
if (window.Reo) {
window.Reo.init({ clientID: e });
}
};
n = document.createElement("script");
n.src = "https://static.reo.dev/" + e + "/reo.js";
n.defer = true;
n.onload = t;
document.head.appendChild(n);
}();
`,
}}
/>
) : null}
<Script
id="hubspot-script"
type="text/javascript"
src="https://js.hs-scripts.com/45532593.js"
async
defer
/>
{REB2B_KEY ? (
<Script
id="reb2b-script"
strategy="afterInteractive"
src={`https://b2bjsstore.s3.us-west-2.amazonaws.com/b/${REB2B_KEY}/${REB2B_KEY}.js.gz`}
/>
) : null}
</head>
<body className="min-h-screen">
<AnalyticsClient />
<Suspense fallback={null}>
<PostHogProvider>
<FrameworkProvider knownFrameworks={knownFrameworks}>
<BrandNav />
<main>{children}</main>
</FrameworkProvider>
</PostHogProvider>
</Suspense>
<div
aria-hidden="true"
style={{
position: "fixed",
bottom: "8px",
right: "12px",
fontSize: "10px",
fontFamily: "monospace",
color: "rgba(0,0,0,0.15)",
pointerEvents: "none",
zIndex: 9999,
userSelect: "none",
}}
>
{commitLabel}
</div>
<ScarfPixel />
</body>
</html>
);
}