@@ -3,11 +3,16 @@ import {
33 ResponsiveLayoutSidebar ,
44 ResponsiveLayoutSidebarItem ,
55} from "@/components/docs/ResponsiveLayoutSidebar.tsx" ;
6- import React , { useRef } from "react" ;
7- import { Outlet , useNavigate } from "react-router-dom" ;
6+ import React , { useRef , useState } from "react" ;
7+ import { Outlet , useLocation , useNavigate } from "react-router-dom" ;
8+
9+ function formatSolutionHeader ( current : ResponsiveLayoutSidebarItem | undefined ) {
10+ return current ? `Nossa Solução: ${ current . label } ` : "Nossas Soluções" ;
11+ }
812
913const Reference = ( ) => {
1014 const layoutRef = useRef < ResponsiveLayoutRef > ( null ) ;
15+ const location = useLocation ( ) ;
1116 const navigate = useNavigate ( ) ;
1217 const sidebarItems : ResponsiveLayoutSidebarItem [ ] = [
1318 {
@@ -51,15 +56,20 @@ const Reference = () => {
5156 level : 0 ,
5257 } ,
5358 ] ;
59+ const current = sidebarItems . find ( item => location . pathname === `/docs/reference/${ item . id } ` ) ;
60+ const initialTitle = formatSolutionHeader ( current ) ;
61+ const [ title , setTitle ] = useState ( initialTitle ) ;
5462
5563 const handleItemClick = ( item : ResponsiveLayoutSidebarItem ) => {
64+ setTitle ( formatSolutionHeader ( item ) ) ;
65+ layoutRef . current ?. closeSidebar ( ) ;
5666 navigate ( `/docs/reference/${ item . id } ` ) ;
5767 } ;
5868
5969 return (
6070 < ResponsiveLayout
6171 ref = { layoutRef }
62- title = { "Nossas Soluções" }
72+ title = { title }
6373 leftContent = { < ResponsiveLayoutSidebar items = { sidebarItems } onItemClick = { handleItemClick } /> }
6474 rightContent = {
6575 < div className = "relative" >
0 commit comments