@@ -59,6 +59,7 @@ const Navbar: FC<NavbarProps> = ({ handleToggleSidebar, handleClick }) => {
5959 logo : isDarkTheme ? < ToolsIcon /> : < ToolsDarkIcon /> ,
6060 target : '' ,
6161 id : 'tools' ,
62+ activeMatch : '/tools/longevity-protocol' ,
6263 } ,
6364 {
6465 name : articles ,
@@ -81,31 +82,38 @@ const Navbar: FC<NavbarProps> = ({ handleToggleSidebar, handleClick }) => {
8182 [ styles . authorized ] : ! ! accountData ,
8283 } ) }
8384 >
84- { routes . map ( ( { name, path, target, logo, id } , index ) => (
85- < a
86- key = { index }
87- href = { path }
88- target = { target }
89- onClick = { e => {
90- if ( target === '_blank' ) return ;
91- e . preventDefault ( ) ;
92- if ( isSmallScreen ) handleToggleSidebar ( ) ;
93- handleClick ( e , path ) ;
94- } }
95- className = { cn ( styles . url , {
96- [ styles . active ] :
97- path === '/'
98- ? router . asPath === '/'
99- : router . asPath . startsWith ( path ) ,
100- [ styles . uxcoreIcon ] : id === 'uxcore' ,
101- [ styles . companyManagementIcon ] : id === 'companyManagement' ,
102- [ styles . articlesIcon ] : id === 'articles' ,
103- [ styles . ruUrl ] : locale === 'ru' ,
104- } ) }
105- >
106- { logo } { name }
107- </ a >
108- ) ) }
85+ { routes . map ( ( { name, path, target, logo, id, activeMatch } , index ) => {
86+ const match = activeMatch ?? path ;
87+
88+ const isActive =
89+ match === '/'
90+ ? router . asPath === '/'
91+ : router . asPath . startsWith ( match ) ;
92+
93+ return (
94+ < a
95+ key = { index }
96+ href = { path }
97+ target = { target }
98+ onClick = { e => {
99+ if ( target === '_blank' ) return ;
100+ e . preventDefault ( ) ;
101+ if ( isSmallScreen ) handleToggleSidebar ( ) ;
102+ handleClick ( e , path ) ;
103+ } }
104+ className = { cn ( styles . url , {
105+ [ styles . active ] : isActive ,
106+ [ styles . uxcoreIcon ] : id === 'uxcore' ,
107+ [ styles . companyManagementIcon ] : id === 'companyManagement' ,
108+ [ styles . articlesIcon ] : id === 'articles' ,
109+ [ styles . ruUrl ] : locale === 'ru' ,
110+ } ) }
111+ >
112+ { logo } { name }
113+ </ a >
114+ ) ;
115+ } ) }
116+
109117 < a
110118 href = { '/contributors' }
111119 onClick = { e => {
0 commit comments