@@ -34,7 +34,8 @@ export const Header = memo(function Header({
3434 navItems,
3535 socialLinks,
3636 languages,
37- currentLocale = 'en'
37+ currentLocale = 'en' ,
38+ currentType = 'docs'
3839} : HeaderConfig ) {
3940 const [ isMounted , setIsMounted ] = useState ( false )
4041 const { theme, setTheme } = useTheme ( )
@@ -104,31 +105,36 @@ export const Header = memo(function Header({
104105
105106 // Memoize the navigation items
106107 const navigationItems = useMemo ( ( ) => {
107- return navItems ?. filter ( ( item ) => item . show ) . map ( ( item , index ) => (
108- < motion . div
109- key = { index }
110- initial = { { opacity : 0 , y : - 20 } }
111- animate = { { opacity : 1 , y : 0 } }
112- exit = { { opacity : 0 , y : - 20 } }
113- transition = { { delay : index * 0.1 } }
114- >
115- < Link
116- href = { item . href }
117- className = { `group relative flex items-center gap-x-2 text-sm font-medium transition-colors px-3 py-2 rounded-md
118- ${ pathname === item . href
119- ? 'text-foreground bg-muted'
120- : 'text-muted-foreground hover:text-foreground'
121- } `}
108+ return navItems ?. filter ( ( item ) => item . show ) . map ( ( item , index ) => {
109+ // Check if the current nav item matches the page type
110+ const isActive = currentType ? item . href . includes ( `/${ currentType } ` ) : pathname === item . href ;
111+
112+ return (
113+ < motion . div
114+ key = { index }
115+ initial = { { opacity : 0 , y : - 20 } }
116+ animate = { { opacity : 1 , y : 0 } }
117+ exit = { { opacity : 0 , y : - 20 } }
118+ transition = { { delay : index * 0.1 } }
122119 >
123- { t ( item . label as string ) }
124- < span
125- className = { `absolute inset-x-0 -bottom-px h-0.5 bg-primary transition-transform duration-150 ease-in-out
126- ${ pathname === item . href ? 'scale-x-100' : 'scale-x-0 group-hover:scale-x-100' } ` }
127- />
128- </ Link >
129- </ motion . div >
130- ) )
131- } , [ navItems , pathname ] )
120+ < Link
121+ href = { item . href }
122+ className = { `group relative flex items-center gap-x-2 text-sm font-medium transition-colors px-3 py-2 rounded-md
123+ ${ isActive
124+ ? 'text-foreground bg-muted'
125+ : 'text-muted-foreground hover:text-foreground'
126+ } `}
127+ >
128+ { t ( item . label as string ) }
129+ < span
130+ className = { `absolute inset-x-0 -bottom-px h-0.5 bg-primary transition-transform duration-150 ease-in-out
131+ ${ isActive ? 'scale-x-100' : 'scale-x-0 group-hover:scale-x-100' } ` }
132+ />
133+ </ Link >
134+ </ motion . div >
135+ ) ;
136+ } ) ;
137+ } , [ navItems , pathname , currentType ] ) ;
132138
133139 return (
134140 < motion . header
0 commit comments