@@ -11,7 +11,6 @@ import SearchDialogButton from "@/components/ui/search-button"
1111import MobileSidebar from "@/components/layout/mobile-sidebar"
1212// Icons
1313import RocketIcon from "@/components/ui/icons/rocket"
14- import PuzzleIcon from "@/components/ui/icons/puzzle"
1514import ConsoleIcon from "@/components/ui/icons/console"
1615import CloudIcon from "@/components/ui/icons/cloud"
1716import GithubIcon from "@/components/ui/icons/github"
@@ -34,14 +33,9 @@ interface NavbarProps {
3433export const LEFT_LINKS : NavbarLink [ ] = [
3534 {
3635 icon : < RocketIcon /> ,
37- label : "Overview " ,
36+ label : "Documentation " ,
3837 href : "/" ,
3938 } ,
40- {
41- icon : < PuzzleIcon /> ,
42- label : "Integrations" ,
43- href : "/integrations" ,
44- } ,
4539 {
4640 icon : < ConsoleIcon /> ,
4741 label : "API Reference" ,
@@ -57,11 +51,6 @@ export const LEFT_LINKS: NavbarLink[] = [
5751]
5852
5953const RIGHT_LINKS : NavbarLink [ ] = [
60- {
61- icon : < ConsoleIcon /> ,
62- href : "/reference" ,
63- label : "API Reference" ,
64- } ,
6554 {
6655 icon : < CloudIcon /> ,
6756 href : "https://cloud.copilotkit.ai" ,
@@ -82,8 +71,28 @@ const RIGHT_LINKS: NavbarLink[] = [
8271
8372const Navbar = ( { pageTree } : NavbarProps ) => {
8473 const [ isMobileSidebarOpen , setIsMobileSidebarOpen ] = useState ( false )
74+ const [ lastDocsPath , setLastDocsPath ] = useState < string | null > ( null )
8575 const pathname = usePathname ( )
86- const activeRoute = pathname === "/" ? "/" : `/${ pathname . split ( "/" ) [ 1 ] } `
76+
77+ // Read localStorage on client only to avoid hydration mismatch
78+ useEffect ( ( ) => {
79+ setLastDocsPath ( localStorage . getItem ( 'lastDocsPath' ) )
80+ } , [ ] )
81+
82+ // Determine active route based on current path
83+ const firstSegment = pathname === "/" ? "/" : `/${ pathname . split ( "/" ) [ 1 ] } `
84+ const isReferencePage = firstSegment === "/reference"
85+ // Reference pages → /reference, Everything else (root + integrations) → /
86+ const activeRoute = isReferencePage ? "/reference" : "/"
87+
88+ // Get the appropriate href for Documentation link
89+ const getDocumentationHref = ( ) => {
90+ // If we're on a reference page, try to restore last docs path
91+ if ( isReferencePage && lastDocsPath ) {
92+ return lastDocsPath
93+ }
94+ return '/'
95+ }
8796
8897 // Close mobile sidebar when viewport expands beyond mobile breakpoint (md: 768px)
8998 useEffect ( ( ) => {
@@ -126,15 +135,17 @@ const Navbar = ({ pageTree }: NavbarProps) => {
126135 < Logo className = "pl-6" />
127136 < ul className = "hidden gap-6 items-center h-full md:flex" >
128137 { LEFT_LINKS . map ( ( link ) => {
129- // Hide API Reference and Copilot Cloud at narrow widths
130- const hideAtNarrow = link . label === "API Reference" || link . label === "Copilot Cloud" ;
131- // Hide icons for Overview and Integrations at very narrow widths
132- const hideIconAtNarrow = link . label === "Overview" || link . label === "Integrations" ;
133-
138+ // Hide only Copilot Cloud at narrow widths
139+ const hideAtNarrow = link . label === "Copilot Cloud" ;
140+ // Hide icons for Documentation and API Reference at very narrow widths
141+ const hideIconAtNarrow = link . label === "Documentation" || link . label === "API Reference" ;
142+ // Use dynamic href for Documentation link
143+ const href = link . label === "Documentation" ? getDocumentationHref ( ) : link . href ;
144+
134145 return (
135- < li key = { link . href } className = { `relative h-full group ${ hideAtNarrow ? '[@media(width<1112px )]:hidden' : '' } ` } >
146+ < li key = { link . href } className = { `relative h-full group ${ hideAtNarrow ? '[@media(width<1028px )]:hidden' : '' } ` } >
136147 < Link
137- href = { link . href }
148+ href = { href }
138149 target = { link . target }
139150 className = { `h-full ${
140151 activeRoute === link . href ? "opacity-100" : "opacity-50"
@@ -201,15 +212,15 @@ const Navbar = ({ pageTree }: NavbarProps) => {
201212 style = { { backgroundColor : 'var(--sidebar)' } }
202213 >
203214 { RIGHT_LINKS . map ( ( link ) => {
204- // For API Reference and Copilot Cloud, only show at narrow widths (between 768px and 1112px )
205- const isIconOnlyLink = link . label === "API Reference" || link . label === " Copilot Cloud";
206-
215+ // Only show Copilot Cloud at narrow widths (between 768px and 1028px )
216+ const isIconOnlyLink = link . label === "Copilot Cloud" ;
217+
207218 return (
208219 < Link
209220 key = { link . href }
210221 href = { link . href }
211222 target = { link . target }
212- className = { `${ isIconOnlyLink ? '[@media(width>=1112px )]:hidden [@media(width<768px)]:hidden' : 'hidden' } justify-center items-center w-11 h-full md:flex` }
223+ className = { `${ isIconOnlyLink ? '[@media(width>=1028px )]:hidden [@media(width<768px)]:hidden' : 'hidden' } justify-center items-center w-11 h-full md:flex` }
213224 title = { link . label }
214225 suppressHydrationWarning = { link . target === "_blank" }
215226 >
0 commit comments