@@ -13,52 +13,13 @@ interface FooterSection {
1313interface FooterProps {
1414 client : GraphClient ;
1515 currentPath : string ;
16- sections ?: FooterSection [ ] ;
1716}
1817
19- const defaultSections : FooterSection [ ] = [
20- {
21- title : 'PRODUCTS' ,
22- links : [
23- { label : 'Alloy Plan' , href : '/en/alloy-plan' } ,
24- { label : 'Alloy Track' , href : '/en/alloy-track' } ,
25- { label : 'Alloy Meet' , href : '/en/alloy-meet' } ,
26- ] ,
27- } ,
28- {
29- title : 'THE COMPANY' ,
30- links : [
31- { label : 'History' , href : '/en/history' } ,
32- { label : 'News & Events' , href : '/en/news' } ,
33- { label : 'Management' , href : '/en/management' } ,
34- { label : 'Contact us' , href : '/en/contact' } ,
35- { label : 'Become a reseller' , href : '/en/reseller' } ,
36- ] ,
37- } ,
38- {
39- title : 'NEWS & EVENTS' ,
40- links : [
41- { label : 'Events' , href : '/en/events' } ,
42- { label : 'Press Releases' , href : '/en/press' } ,
43- ] ,
44- } ,
45- {
46- title : 'CUSTOMER ZONE' ,
47- links : [
48- { label : 'Reseller extranet' , href : '/en/reseller-extranet' } ,
49- { label : 'Log out' , href : '/en/logout' } ,
50- ] ,
51- } ,
52- ] ;
53-
54- async function Footer ( {
55- client,
56- currentPath,
57- sections = defaultSections ,
58- } : FooterProps ) {
18+ async function Footer ( { client, currentPath } : FooterProps ) {
5919 const allLinks = await Promise . all ( [
6020 client . getItems ( '/en/' ) ,
6121 client . getItems ( '/en/about-us' ) ,
22+ client . getItems ( '/en/about-us/news-events' ) ,
6223 ] ) ;
6324
6425 // Flatten the array of arrays and map to FooterLink format
@@ -68,17 +29,36 @@ async function Footer({
6829 href : ancestor . _metadata ?. url ?. hierarchical ,
6930 } ) ) ;
7031
71- console . info (
72- 'Footer footerLinks:' ,
73- currentPath ,
74- JSON . stringify ( footerLinks , null , 2 )
32+ // Group links by category based on URL patterns
33+ const categorizedLinks = footerLinks . reduce < {
34+ products : FooterLink [ ] ;
35+ company : FooterLink [ ] ;
36+ news : FooterLink [ ] ;
37+ } > (
38+ ( acc , link ) => {
39+ if ( link . href ?. match ( / \/ a b o u t - u s \/ n e w s - e v e n t s \/ .+ / ) ) {
40+ acc . news . push ( { label : link . label , href : link . href } ) ;
41+ } else if ( link . href ?. includes ( '/about-us' ) ) {
42+ acc . company . push ( { label : link . label , href : link . href } ) ;
43+ } else if ( link . href ) {
44+ acc . products . push ( { label : link . label , href : link . href } ) ;
45+ }
46+ return acc ;
47+ } ,
48+ { products : [ ] , company : [ ] , news : [ ] }
7549 ) ;
7650
51+ const formattedFooterLink : FooterSection [ ] = [
52+ { title : 'PRODUCTS' , links : categorizedLinks . products } ,
53+ { title : 'THE COMPANY' , links : categorizedLinks . company } ,
54+ { title : 'NEWS & EVENTS' , links : categorizedLinks . news } ,
55+ ] ;
56+
7757 return (
7858 < footer className = "bg-gray-800 text-white" >
7959 < div className = "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12" >
8060 < div className = "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8" >
81- { sections . map ( ( section , index ) => (
61+ { formattedFooterLink . map ( ( section , index ) => (
8262 < div key = { index } className = "space-y-4" >
8363 < h3 className = "text-sm font-bold uppercase tracking-wider text-white" >
8464 { section . title }
0 commit comments