11import Link from 'next/link' ;
2-
3- interface NavigationItem {
4- label : string ;
5- href : string ;
6- }
2+ import { GraphClient } from '@optimizely/cms-sdk' ;
73
84interface HeaderProps {
9- currentPath : any ;
10- navigationItems ?: NavigationItem [ ] ;
5+ client : GraphClient ;
6+ currentPath : string ;
117 logoText ?: string ;
128}
139
14- const defaultNavigationItems : NavigationItem [ ] = [
15- { label : 'ALLOY PLAN' , href : '/en/alloy-plan' } ,
16- { label : 'ALLOY TRACK' , href : '/en/alloy-track' } ,
17- { label : 'ALLOY MEET' , href : '/en/alloy-meet' } ,
18- { label : 'ABOUT US' , href : '/en/about-us' } ,
19- ] ;
20-
21- async function Header ( {
22- currentPath,
23- navigationItems = defaultNavigationItems ,
24- } : HeaderProps ) {
25- const ancestors = currentPath ?. ancestors || [ ] ;
10+ async function Header ( { client, currentPath } : HeaderProps ) {
11+ const ancestors = ( await client . getPath ( currentPath ) ) || [ ] ;
12+ const navLinks = ( await client . getItems ( '/en/' ) ) ?? [ ] ;
2613
2714 // Filter out the start page (first item) and create breadcrumbs
2815 const breadcrumbs = ancestors . slice ( 1 ) . map ( ( ancestor : any ) => ( {
16+ key : ancestor . _metadata . key ,
17+ label : ancestor . _metadata . displayName ,
18+ href : ancestor . _metadata . url . hierarchical ,
19+ } ) ) ;
20+
21+ // Create navigation from navLinks of the /en/ page
22+ const navigations = navLinks . map ( ( ancestor : any ) => ( {
23+ key : ancestor . _metadata . key ,
2924 label : ancestor . _metadata . displayName ,
3025 href : ancestor . _metadata . url . hierarchical ,
3126 } ) ) ;
@@ -39,12 +34,12 @@ async function Header({
3934 < nav className = "hidden md:flex md:items-center md:space-x-8" >
4035 < div className = "flex-shrink-0" >
4136 { /* Logo */ }
42- < img src = "/logo.png" alt = "Logo" className = "h-14 w-14" />
37+ { /* <img src="/logo.png" alt="Logo" className="h-14 w-14" /> */ }
4338 </ div >
4439 < div className = "flex items-center space-x-8" >
45- { navigationItems . map ( ( item , index ) => (
40+ { navigations . map ( ( item ) => (
4641 < a
47- key = { index }
42+ key = { item . key }
4843 href = { item . href }
4944 className = "text-gray-700 hover:text-teal-600 transition-colors duration-200 text-lg font-extrabold uppercase tracking-wide"
5045 >
0 commit comments