Files
page-agent/packages/website/src/pages/docs/Layout.tsx
T

109 lines
3.3 KiB
TypeScript
Raw Normal View History

2025-09-29 16:33:15 +08:00
import { ReactNode } from 'react'
2025-10-22 22:35:25 +08:00
import { useTranslation } from 'react-i18next'
2025-09-29 16:33:15 +08:00
import { Link, useLocation } from 'wouter'
interface DocsLayoutProps {
children: ReactNode
}
interface NavItem {
title: string
path: string
}
interface NavSection {
title: string
items: NavItem[]
}
export default function DocsLayout({ children }: DocsLayoutProps) {
2025-10-22 22:35:25 +08:00
const { t } = useTranslation('common')
2025-09-29 16:33:15 +08:00
const [location] = useLocation()
2025-10-22 22:35:25 +08:00
const navigationSections: NavSection[] = [
{
title: t('nav.introduction'),
items: [
2026-01-17 01:36:15 +08:00
{ title: t('nav.overview'), path: '/introduction/overview' },
{ title: t('nav.quick_start'), path: '/introduction/quick-start' },
{ title: t('nav.limitations'), path: '/introduction/limitations' },
2025-10-22 22:35:25 +08:00
],
},
{
title: t('nav.features'),
items: [
2026-01-17 01:36:15 +08:00
{ title: t('nav.models'), path: '/features/models' },
{ title: t('nav.custom_tools'), path: '/features/custom-tools' },
{ title: t('nav.knowledge_injection'), path: '/features/custom-instructions' },
{ title: t('nav.data_masking'), path: '/features/data-masking' },
{ title: '🧪 ' + t('nav.chrome_extension'), path: '/features/chrome-extension' },
2025-10-22 22:35:25 +08:00
],
},
{
title: t('nav.integration'),
items: [
2026-01-17 01:36:15 +08:00
{ title: t('nav.third_party_agent'), path: '/integration/third-party-agent' },
{ title: t('nav.cdn_setup'), path: '/integration/cdn-setup' },
2026-01-11 01:40:21 +08:00
{
title: '🚧 ' + t('nav.security_permissions'),
2026-01-17 01:36:15 +08:00
path: '/integration/security-permissions',
2026-01-11 01:40:21 +08:00
},
2026-01-17 01:36:15 +08:00
{ title: '🚧 ' + t('nav.best_practices'), path: '/integration/best-practices' },
2025-10-22 22:35:25 +08:00
],
},
{
title: t('nav.advanced'),
items: [
{ title: t('nav.page_agent'), path: '/advanced/page-agent' },
{ title: t('nav.page_agent_core'), path: '/advanced/page-agent-core' },
],
},
2025-10-22 22:35:25 +08:00
]
2025-09-29 16:33:15 +08:00
return (
<div className="max-w-7xl mx-auto px-6 py-8 overflow-x-auto">
2026-01-17 01:27:19 +08:00
<div className="flex gap-8 min-w-225">
2025-09-29 16:33:15 +08:00
{/* Sidebar */}
2025-11-26 20:41:55 +08:00
<aside className="w-64 shrink-0" role="complementary" aria-label="文档导航">
2026-01-11 01:40:21 +08:00
<div className="sticky">
2025-09-29 16:33:15 +08:00
<nav className="space-y-8" role="navigation" aria-label="文档章节">
{navigationSections.map((section) => (
<section key={section.title}>
2025-10-22 22:35:25 +08:00
<h3 className="font-semibold text-gray-600 dark:text-gray-400 uppercase tracking-wider mb-3">
{section.title}
</h3>
2025-09-29 16:33:15 +08:00
<ul className="space-y-2" role="list">
{section.items.map((item) => {
const isActive = location === item.path
return (
<li key={item.path}>
<Link
href={item.path}
className={`block px-3 py-2 rounded-lg transition-colors duration-200 ${
isActive
? 'bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium'
2025-10-22 22:35:25 +08:00
: 'text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800'
2025-09-29 16:33:15 +08:00
}`}
aria-current={isActive ? 'page' : undefined}
>
{item.title}
</Link>
</li>
)
})}
</ul>
</section>
))}
</nav>
</div>
</aside>
{/* Main Content */}
<main className="flex-1 min-w-0" id="main-content" role="main">
<div className="prose prose-lg dark:prose-invert max-w-none">{children}</div>
</main>
</div>
</div>
)
}