Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

refactor component structure for seo readability

Ben Fornefeld2d47c15422a9
diff --git a/apps/web/src/components/LegacyBanner.tsx b/apps/web/src/components/LegacyBanner.tsx
new file mode 100644
index 000000000..346ea40da
--- /dev/null
+++ b/apps/web/src/components/LegacyBanner.tsx
@@ -0,0 +1,27 @@
+'use client'
+
+import { AlertCircle } from 'lucide-react'
+import { usePathname } from 'next/navigation'
+
+export default function LegacyBanner() {
+ const pathname = usePathname()
+
+ const isLegacy = pathname?.startsWith('/docs/legacy')
+
+ if (!isLegacy) return null
+
+ return (
+ <>
+ <div className="sticky top-[5rem] inset-x-0 z-10">
+ <div className="flex items-center gap-2 max-w-6xl mx-auto w-fit px-4 py-3 rounded-2xl bg-gradient-to-b from-zinc-800 to-zinc-900 text-zinc-400 ring-1 ring-inset ring-zinc-700">
+ <AlertCircle className="h-4 w-4 text-brand-400/80" />
+ <span>
+ You are reading a <span className="text-brand-400/90">legacy</span>{' '}
+ document.
+ </span>
+ </div>
+ </div>
+ <div className="h-16" />
+ </>
+ )
+}
diff --git a/apps/web/src/components/mdx.tsx b/apps/web/src/components/mdx.tsx
index 3aa71455f..c65749cd0 100644
--- a/apps/web/src/components/mdx.tsx
+++ b/apps/web/src/components/mdx.tsx
@@ -1,12 +1,9 @@
-'use client'
-
import Link from 'next/link'
import clsx from 'clsx'
import { Heading } from '@/components/Heading'
import { Prose } from '@/components/Prose'
-import { usePathname } from 'next/navigation'
-import { AlertCircle } from 'lucide-react'
+import LegacyBanner from './LegacyBanner'
export const a = Link
export { Button } from '@/components/Button'
@@ -19,28 +16,10 @@ export {
export { LanguageSpecificText } from '@/components/LanguageSpecificText'
export function wrapper({ children }: { children: React.ReactNode }) {
- // eslint-disable-next-line react-hooks/rules-of-hooks
- const pathname = usePathname()
-
- const isLegacy = pathname?.startsWith('/docs/legacy')
-
return (
<article className="mx-auto flex h-full max-w-6xl flex-col pb-10 pt-20 md:pt-18">
<Prose className="flex-auto">
- {isLegacy && (
- <>
- <div className="sticky top-[5rem] inset-x-0 z-10">
- <div className="flex items-center gap-2 max-w-6xl mx-auto w-fit px-4 py-3 rounded-2xl bg-gradient-to-b from-zinc-800 to-zinc-900 text-zinc-400 ring-1 ring-inset ring-zinc-700">
- <AlertCircle className="h-4 w-4 text-brand-400/80" />
- <span>
- You are reading a{' '}
- <span className="text-brand-400/90">legacy</span> document.
- </span>
- </div>
- </div>
- <div className="h-16" />
- </>
- )}
+ <LegacyBanner />
{children}
</Prose>
</article>