1+ import Link from 'next/link' ;
2+
13interface NavigationItem {
24 label : string ;
35 href : string ;
46}
57
68interface HeaderProps {
9+ currentPath : any ;
710 navigationItems ?: NavigationItem [ ] ;
811 logoText ?: string ;
912}
@@ -15,55 +18,106 @@ const defaultNavigationItems: NavigationItem[] = [
1518 { label : 'ABOUT US' , href : '/en/about-us' } ,
1619] ;
1720
18- function Header ( { navigationItems = defaultNavigationItems } : HeaderProps ) {
21+ async function Header ( {
22+ currentPath,
23+ navigationItems = defaultNavigationItems ,
24+ } : HeaderProps ) {
25+ const ancestors = currentPath ?. ancestors || [ ] ;
26+
27+ // Filter out the start page (first item) and create breadcrumbs
28+ const breadcrumbs = ancestors . slice ( 1 ) . map ( ( ancestor : any ) => ( {
29+ label : ancestor . _metadata . displayName ,
30+ href : ancestor . _metadata . url . hierarchical ,
31+ } ) ) ;
32+
1933 return (
20- < header className = "bg-gray-100 border-b border-gray-200" >
21- < div className = "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8" >
22- < div className = "flex items-center justify-between h-28" >
23- { /* Navigation */ }
24- < nav className = "hidden md:flex md:items-center md:space-x-8" >
25- < div className = "flex-shrink-0" >
26- { /* Logo */ }
27- < img src = "/logo.png" alt = "Logo" className = "h-14 w-14" />
28- </ div >
29- < div className = "flex items-center space-x-8" >
30- { navigationItems . map ( ( item , index ) => (
31- < a
32- key = { index }
33- href = { item . href }
34- className = "text-gray-700 hover:text-teal-600 transition-colors duration-200 text-lg font-extrabold uppercase tracking-wide"
35- >
36- { item . label }
37- </ a >
38- ) ) }
39- </ div >
40- </ nav >
34+ < >
35+ < header className = "bg-gray-100 border-b border-gray-200" >
36+ < div className = "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8" >
37+ < div className = "flex items-center justify-between h-28" >
38+ { /* Navigation */ }
39+ < nav className = "hidden md:flex md:items-center md:space-x-8" >
40+ < div className = "flex-shrink-0" >
41+ { /* Logo */ }
42+ < img src = "/logo.png" alt = "Logo" className = "h-14 w-14" />
43+ </ div >
44+ < div className = "flex items-center space-x-8" >
45+ { navigationItems . map ( ( item , index ) => (
46+ < a
47+ key = { index }
48+ href = { item . href }
49+ className = "text-gray-700 hover:text-teal-600 transition-colors duration-200 text-lg font-extrabold uppercase tracking-wide"
50+ >
51+ { item . label }
52+ </ a >
53+ ) ) }
54+ </ div >
55+ </ nav >
4156
42- { /* Mobile menu button */ }
43- < div className = "md:hidden" >
44- < button
45- type = "button"
46- className = "text-gray-700 hover:text-teal-600 focus:outline-none focus:text-teal-600"
47- aria-label = "Open menu"
48- >
49- < svg
50- className = "h-6 w-6"
51- fill = "none"
52- viewBox = "0 0 24 24"
53- stroke = "currentColor"
57+ { /* Mobile menu button */ }
58+ < div className = "md:hidden" >
59+ < button
60+ type = "button"
61+ className = "text-gray-700 hover:text-teal-600 focus:outline-none focus:text-teal-600"
62+ aria-label = "Open menu"
5463 >
55- < path
56- strokeLinecap = "round"
57- strokeLinejoin = "round"
58- strokeWidth = { 2 }
59- d = "M4 6h16M4 12h16M4 18h16"
60- />
61- </ svg >
62- </ button >
64+ < svg
65+ className = "h-6 w-6"
66+ fill = "none"
67+ viewBox = "0 0 24 24"
68+ stroke = "currentColor"
69+ >
70+ < path
71+ strokeLinecap = "round"
72+ strokeLinejoin = "round"
73+ strokeWidth = { 2 }
74+ d = "M4 6h16M4 12h16M4 18h16"
75+ />
76+ </ svg >
77+ </ button >
78+ </ div >
6379 </ div >
6480 </ div >
65- </ div >
66- </ header >
81+ </ header >
82+
83+ { /* Breadcrumbs */ }
84+ { breadcrumbs . length > 0 && (
85+ < nav
86+ className = "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4"
87+ aria-label = "Breadcrumb"
88+ >
89+ < ol className = "flex items-center space-x-1" >
90+ < li >
91+ < Link
92+ href = { ancestors [ 0 ] ?. _metadata ?. url ?. hierarchical || '/' }
93+ className = "text-[#1cb898] hover:text-gray-700"
94+ >
95+ Home
96+ </ Link >
97+ </ li >
98+ { breadcrumbs . map (
99+ ( crumb : { label : string ; href : string } , index : number ) => (
100+ < li key = { index } className = "flex items-center" >
101+ < span className = "text-gray-400 mx-1" > /</ span >
102+ { index === breadcrumbs . length - 1 ? (
103+ < span className = "text-gray-700 font-medium" >
104+ { crumb . label }
105+ </ span >
106+ ) : (
107+ < Link
108+ href = { crumb . href }
109+ className = "text-gray-500 hover:text-gray-700"
110+ >
111+ { crumb . label }
112+ </ Link >
113+ ) }
114+ </ li >
115+ )
116+ ) }
117+ </ ol >
118+ </ nav >
119+ ) }
120+ </ >
67121 ) ;
68122}
69123
0 commit comments