diff --git a/app/(docs)/[...slug]/page.tsx b/app/(docs)/[...slug]/page.tsx deleted file mode 100644 index bce4398b3..000000000 --- a/app/(docs)/[...slug]/page.tsx +++ /dev/null @@ -1,296 +0,0 @@ -import fs from 'node:fs/promises'; -import defaultMdxComponents from 'fumadocs-ui/mdx'; -import matter from 'gray-matter'; -import * as lucideIcons from 'lucide-react'; -import { CheckIcon } from 'lucide-react'; -import { notFound } from 'next/navigation'; -import { Callout } from '@/components/callout'; -import { FeedbackWrapper } from '@/components/feedback/feedback-wrapper'; -import { InteractiveHeader, InteractiveLayout } from '@/components/layouts/interactive'; -import { - DocsPage, - DocsPageBreadcrumb, - DocsPageContent, - DocsPageContentWrapper, - DocsPageDescription, - DocsPageHeader, - DocsPageLayout, - DocsPageProse, - DocsPageTitle, -} from '@/components/layouts/page'; -import { LLMShare } from '@/components/llm-share'; -import { getMDXComponents } from '@/components/mdx'; -import { Mermaid } from '@/components/mdx/mermaid'; -import { APIPage } from '@/components/openapi/api-page'; -import { API } from '@/components/reference/api-page'; -import { Badge } from '@/components/ui/badge'; -import * as customIcons from '@/components/ui/icon'; -import { TagFilterSystem } from '@/components/ui/tag-filter-system'; -import { getAllFilterablePages, source } from '@/lib/source'; -import type { HeadingProps } from '@/types'; - -export default async function Page(props: { params: Promise<{ slug?: string[] }> }) { - const params = await props.params; - const page = source.getPage(params.slug); - if (!page) notFound(); - - const fileContent = await fs.readFile(page.data._file.absolutePath, 'utf-8'); - const { content: rawMarkdownContent } = matter(fileContent); - - const LLMContent = rawMarkdownContent - .split('\n') - .filter((line) => !line.trim().startsWith('import')) - .join('\n') - .trim(); - - const MDX = page.data.body; - - if (!MDX) { - console.error('MDX component is undefined for page:', page.url); - notFound(); - } - - // Get all filterable pages for tag filtering - const allFilterablePages = getAllFilterablePages(); - - // Extract section from current page URL for scoped filtering - const currentSection = page.url.split('/').filter(Boolean)[1] || 'general'; - - // Helper function to get icon component - const getIconComponent = (iconName: string) => { - const iconProps = { className: 'w-3 h-3 shrink-0' }; - - // Check custom icons first - const CustomIcon = (customIcons as any)[iconName]; - if (CustomIcon && typeof CustomIcon === 'function') { - return ; - } - - // Try with "Icon" suffix for custom icons - const CustomIconWithSuffix = (customIcons as any)[`${iconName}Icon`]; - if (CustomIconWithSuffix && typeof CustomIconWithSuffix === 'function') { - return ; - } - - // Check lucide icons - try multiple naming patterns - const lucidePatterns = [ - iconName, // exact name - `${iconName}Icon`, // with Icon suffix - iconName.charAt(0).toUpperCase() + iconName.slice(1), // capitalize first letter - `${iconName.charAt(0).toUpperCase() + iconName.slice(1)}Icon`, // capitalize + Icon - ]; - - for (const pattern of lucidePatterns) { - const LucideIcon = (lucideIcons as any)[pattern]; - if (LucideIcon && typeof LucideIcon === 'function') { - return ; - } - } - - return null; - }; - - // Convert icon names to React components - const interactiveLinks = page.data.interactiveLinks?.map((link) => ({ - ...link, - icon: link.icon ? getIconComponent(link.icon) : undefined, - })); - - // Prepare page data for context - only include serializable data - const pageData = { - toc: page.data.toc, - full: page.data.full, - interactive: page.data.interactive, - title: page.data.title, - description: page.data.description, - interactiveFeatures: page.data.interactiveFeatures, - interactiveLinks, // Use the processed links with React components - }; - - return ( - - {page.data.interactive ? ( - - - - - - -
- - - - - , - APIPage: (props) => ( - - ), - h1: ({ children, ...props }: HeadingProps) => { - const H1 = defaultMdxComponents.h1 as React.ComponentType; - const id = typeof children === 'string' ? children : undefined; - return ( -

- {children} -

- ); - }, - blockquote: (props) => {props.children}, - code: (props: React.PropsWithChildren) => ( - - ), - hr: (props: React.PropsWithChildren) => ( -
- ), - input: (props: React.InputHTMLAttributes) => { - if (props.type === 'checkbox') { - return ( -
- -
- {props.checked && } -
-
- ); - } - return ; - }, - Mermaid, - })} - /> -
-
- - - - - ) : ( - - - - -
-
- - {page.data.isRpc && ( - - RPC node - - )} -
- {page.data.llm !== false && } -
- - - {/* Render TagFilterSystem if tags are present in frontmatter */} - {page.data.tags && page.data.tags.length > 0 && ( - - )} - -
- - , - APIPage: (props) => ( - - ), - h1: ({ children, ...props }: HeadingProps) => { - const H1 = defaultMdxComponents.h1 as React.ComponentType; - const id = typeof children === 'string' ? children : undefined; - return ( -

- {children} -

- ); - }, - blockquote: (props) => {props.children}, - code: (props: React.PropsWithChildren) => ( - - ), - hr: (props: React.PropsWithChildren) => ( -
- ), - input: (props: React.InputHTMLAttributes) => { - if (props.type === 'checkbox') { - return ( -
- -
- {props.checked && } -
-
- ); - } - return ; - }, - Mermaid, - })} - /> -
-
- - - - - )} - - ); -} - -export async function generateStaticParams() { - return source.generateParams().filter( - (params) => - // Filter out empty slug arrays (root path) - params.slug && params.slug.length > 0, - ); -} - -export async function generateMetadata(props: { params: Promise<{ slug?: string[] }> }) { - const params = await props.params; - const page = source.getPage(params.slug); - if (!page) notFound(); - - return { - title: page.data.title, - description: page.data.description, - }; -} diff --git a/app/(docs)/error.tsx b/app/(docs)/error.tsx deleted file mode 100644 index 39a19cc5b..000000000 --- a/app/(docs)/error.tsx +++ /dev/null @@ -1,60 +0,0 @@ -'use client'; - -import Link from 'next/link'; -import React from 'react'; - -export default function ErrorBoundary({ - error, - reset, -}: { - error: Error & { digest?: string }; - reset: () => void; -}) { - React.useEffect(() => { - // Hide sidebar for errors (including 404s) - const aside = document.querySelector('aside'); - if (aside) { - aside.style.display = 'none'; - } - - return () => { - const asideCleanup = document.querySelector('aside'); - if (asideCleanup) { - asideCleanup.style.display = ''; - } - }; - }, []); - - // Check if this is likely a 404 error - const is404 = error.message?.includes('404') || error.message?.includes('not found'); - - return ( -
-

- {is404 ? 'Page not found' : 'Something went wrong'} -

-

- {is404 - ? "The documentation you are looking for doesn't exist or has been moved." - : 'An error occurred while loading this page.'} -

-
- - Back to homepage - - {!is404 && ( - - )} -
-
- ); -} diff --git a/app/(docs)/layout.tsx b/app/(docs)/layout.tsx deleted file mode 100644 index a5f895fb0..000000000 --- a/app/(docs)/layout.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import type { ReactNode } from 'react'; -import { baseOptions } from '@/app/layout.config'; -import { DocsLayout } from '@/components/layouts/docs'; -import { source } from '@/lib/source'; - -export default function Layout({ children }: { children: ReactNode }) { - return ( - - {children} - - ); -} diff --git a/app/(docs)/not-found.tsx b/app/(docs)/not-found.tsx deleted file mode 100644 index 8be677752..000000000 --- a/app/(docs)/not-found.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import Link from 'next/link'; - -export default function DocsNotFound() { - return ( - <> -