@@ -10,55 +10,15 @@ import {
1010 SheetContent ,
1111 SheetTitle ,
1212} from "@/components/ui/sheet" ;
13-
14- const navigation = [
15- {
16- title : "Getting Started" ,
17- items : [
18- { title : "Introduction" , href : "/docs" } ,
19- { title : "Installation" , href : "/docs/installation" } ,
20- { title : "Quick Start" , href : "/docs/quick-start" } ,
21- ] ,
22- } ,
23- {
24- title : "Core Concepts" ,
25- items : [
26- { title : "Catalog" , href : "/docs/catalog" } ,
27- { title : "Registry" , href : "/docs/registry" } ,
28- { title : "Data Binding" , href : "/docs/data-binding" } ,
29- { title : "Actions" , href : "/docs/actions" } ,
30- { title : "Visibility" , href : "/docs/visibility" } ,
31- { title : "Validation" , href : "/docs/validation" } ,
32- ] ,
33- } ,
34- {
35- title : "Guides" ,
36- items : [
37- { title : "AI SDK Integration" , href : "/docs/ai-sdk" } ,
38- { title : "Streaming" , href : "/docs/streaming" } ,
39- { title : "Code Export" , href : "/docs/code-export" } ,
40- ] ,
41- } ,
42- {
43- title : "API Reference" ,
44- items : [
45- { title : "@json-render/core" , href : "/docs/api/core" } ,
46- { title : "@json-render/react" , href : "/docs/api/react" } ,
47- { title : "@json-render/codegen" , href : "/docs/api/codegen" } ,
48- ] ,
49- } ,
50- ] ;
51-
52- // Flatten all pages for current page lookup
53- const allPages = navigation . flatMap ( ( section ) => section . items ) ;
13+ import { docsNavigation , allDocsPages } from "@/lib/docs-navigation" ;
5414
5515export function DocsMobileNav ( ) {
5616 const [ open , setOpen ] = useState ( false ) ;
5717 const pathname = usePathname ( ) ;
5818
5919 const currentPage = useMemo ( ( ) => {
60- const page = allPages . find ( ( page ) => page . href === pathname ) ;
61- return page ?? allPages [ 0 ] ;
20+ const page = allDocsPages . find ( ( page ) => page . href === pathname ) ;
21+ return page ?? allDocsPages [ 0 ] ;
6222 } , [ pathname ] ) ;
6323
6424 return (
@@ -72,27 +32,49 @@ export function DocsMobileNav() {
7232 < SheetContent className = "overflow-y-auto p-6" >
7333 < SheetTitle className = "mb-6" > Table of Contents</ SheetTitle >
7434 < nav className = "space-y-6" >
75- { navigation . map ( ( section ) => (
35+ { docsNavigation . map ( ( section ) => (
7636 < div key = { section . title } >
7737 < h4 className = "text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2" >
7838 { section . title }
7939 </ h4 >
8040 < ul className = "space-y-1" >
81- { section . items . map ( ( item ) => (
82- < li key = { item . href } >
83- < Link
84- href = { item . href }
85- onClick = { ( ) => setOpen ( false ) }
86- className = { `text-sm block py-2 transition-colors ${
87- pathname === item . href
88- ? "text-primary font-medium"
89- : "text-muted-foreground hover:text-foreground"
90- } `}
91- >
92- { item . title }
93- </ Link >
94- </ li >
95- ) ) }
41+ { section . items . map ( ( item ) => {
42+ const isExternal = item . external ;
43+ return (
44+ < li key = { item . href } >
45+ < Link
46+ href = { item . href }
47+ onClick = { ( ) => setOpen ( false ) }
48+ { ...( isExternal && {
49+ target : "_blank" ,
50+ rel : "noopener noreferrer" ,
51+ } ) }
52+ className = { `text-sm block py-2 transition-colors ${
53+ pathname === item . href
54+ ? "text-primary font-medium"
55+ : "text-muted-foreground hover:text-foreground"
56+ } ${ isExternal ? "inline-flex items-center gap-1" : "" } `}
57+ >
58+ { item . title }
59+ { isExternal && (
60+ < svg
61+ className = "w-3 h-3"
62+ fill = "none"
63+ stroke = "currentColor"
64+ viewBox = "0 0 24 24"
65+ >
66+ < path
67+ strokeLinecap = "round"
68+ strokeLinejoin = "round"
69+ strokeWidth = { 2 }
70+ d = "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
71+ />
72+ </ svg >
73+ ) }
74+ </ Link >
75+ </ li >
76+ ) ;
77+ } ) }
9678 </ ul >
9779 </ div >
9880 ) ) }
0 commit comments