@@ -99,40 +99,39 @@ function Navbar() {
9999 onClose = { handleCloseNavMenu }
100100 >
101101 { pages . map ( ( page ) => (
102- < Button
103- key = { page }
104- onClick = { ( ) => {
105- if ( page === "Resume" ) {
106- window . open ( Resume , "_blank" ) ; // Open resume in new tab
107- } else if ( page === "Projects" ) {
108- window . location . hash = "#/project" ; // Use hash-based navigation
109- } else if ( page === "Open Source" ) {
110- window . location . hash = "#/opensource" ; // Use hash-based navigation
111- } else {
112- if ( window . location . hash !== "#/" ) {
113- // Store target section in sessionStorage
114- sessionStorage . setItem ( "scrollTo" , page ) ;
115- window . location . hash = "#/" ; // Redirect to homepage
102+ < Button
103+ key = { page }
104+ onClick = { ( ) => {
105+ const slug = page . replace ( / \s + / g, "-" ) . toLowerCase ( ) ;
106+ if ( page === "Resume" ) {
107+ window . open ( Resume , "_blank" ) ; // Open resume in new tab
108+ } else if ( page === "Projects" ) {
109+ window . location . hash = "#/project" ; // Use hash-based navigation
110+ } else if ( page === "Open Source" ) {
111+ window . location . hash = "#/opensource" ; // Use hash-based navigation
116112 } else {
117- document . getElementById ( page ) ?. scrollIntoView ( {
118- behavior : "smooth" ,
119- block : "start" ,
120- } ) ;
113+ if ( window . location . hash !== "#/" ) {
114+ // Store target section in sessionStorage
115+ sessionStorage . setItem ( "scrollTo" , slug ) ;
116+ window . location . hash = "#/" ; // Redirect to homepage
117+ } else {
118+ const el = document . getElementById ( slug ) ;
119+ el ?. scrollIntoView ( { behavior : "smooth" , block : "start" } ) ;
120+ }
121121 }
122- }
123- } }
124- sx = { {
125- my : 0 ,
126- display : "block" ,
127- color : mode == "light" ? "black" : "white" ,
128- p : 1 ,
129- } }
130- >
131- < Typography sx = { { textAlign : "center" } } >
132- { page }
133- </ Typography >
134- </ Button >
135- ) ) }
122+ } }
123+ sx = { {
124+ my : 0 ,
125+ display : "block" ,
126+ color : mode == "light" ? "black" : "white" ,
127+ p : 1 ,
128+ } }
129+ >
130+ < Typography sx = { { textAlign : "center" } } >
131+ { page }
132+ </ Typography >
133+ </ Button >
134+ ) ) }
136135 </ Menu >
137136 </ Box >
138137 < Box
@@ -145,6 +144,7 @@ function Navbar() {
145144 < Button
146145 key = { page }
147146 onClick = { ( ) => {
147+ const slug = page . replace ( / \s + / g, "-" ) . toLowerCase ( ) ;
148148 if ( page === "Resume" ) {
149149 window . open ( Resume , "_blank" ) ; // Open resume in new tab
150150 } else if ( page === "Projects" ) {
@@ -154,13 +154,11 @@ function Navbar() {
154154 } else {
155155 if ( window . location . hash !== "#/" ) {
156156 // Store target section in sessionStorage
157- sessionStorage . setItem ( "scrollTo" , page ) ;
157+ sessionStorage . setItem ( "scrollTo" , slug ) ;
158158 window . location . hash = "#/" ; // Redirect to homepage
159159 } else {
160- document . getElementById ( page ) ?. scrollIntoView ( {
161- behavior : "smooth" ,
162- block : "start" ,
163- } ) ;
160+ const el = document . getElementById ( slug ) ;
161+ el ?. scrollIntoView ( { behavior : "smooth" , block : "start" } ) ;
164162 }
165163 }
166164 } }
@@ -175,13 +173,13 @@ function Navbar() {
175173 display : { justifyContent : "end" } ,
176174 } }
177175 >
178- < IconButton href = "tel:+1-980-358-0053" >
176+ < IconButton component = "a" href = "tel:+1-980-358-0053" aria-label = "call ">
179177 < Phone />
180178 </ IconButton >
181- < IconButton href = "https://www.linkedin.com/in/akshaybheda/" >
179+ < IconButton component = "a" href = "https://www.linkedin.com/in/akshaybheda/" aria-label = "linkedin ">
182180 < LinkedIn />
183181 </ IconButton >
184- < IconButton href = "https://github.com/akshaybheda" >
182+ < IconButton component = "a" href = "https://github.com/akshaybheda" aria-label = "github ">
185183 < GitHub />
186184 </ IconButton >
187185 < IconButton onClick = { toggleDarkMode } >
0 commit comments