File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,15 +13,19 @@ function App() {
1313 return (
1414 < ThemeProvider defaultTheme = "dark" storageKey = "portfolio-theme" >
1515 < Router >
16- < Layout >
17- < Routes >
18- < Route path = "/" element = { < Home /> } />
19- < Route path = "/about" element = { < About /> } />
20- < Route path = "/reading" element = { < Reading /> } />
21- < Route path = "/writing" element = { < Writing /> } />
22- < Route path = "/medium/*" element = { < MediumRedirect /> } />
23- </ Routes >
24- </ Layout >
16+ < Routes >
17+ < Route path = "/medium/*" element = { < MediumRedirect /> } />
18+ < Route path = "/*" element = {
19+ < Layout >
20+ < Routes >
21+ < Route path = "/" element = { < Home /> } />
22+ < Route path = "/about" element = { < About /> } />
23+ < Route path = "/reading" element = { < Reading /> } />
24+ < Route path = "/writing" element = { < Writing /> } />
25+ </ Routes >
26+ </ Layout >
27+ } />
28+ </ Routes >
2529 < Toaster />
2630 </ Router >
2731 </ ThemeProvider >
Original file line number Diff line number Diff line change 11import { useLocation } from "react-router-dom" ;
2- import { useEffect } from "react" ;
32
43const MediumRedirect = ( ) => {
54 const { pathname, search } = useLocation ( ) ;
65
7- useEffect ( ( ) => {
8- let path = pathname . replace ( / ^ \/ + / , "" ) . replace ( / ^ m e d i u m \/ ? / , "" ) ;
9- path = path . replace ( / ^ h t t p s ? : \/ \/ k a p i l l a m b a 4 \. m e d i u m \. c o m \/ ? / i, "" ) ;
10- const target = `https://kapillamba4.medium.com/${ path } ${ search || "" } ` ;
11- window . location . replace ( target ) ;
12- } , [ pathname , search ] ) ;
6+ // Perform redirect immediately during render - no useEffect delay
7+ let path = pathname . replace ( / ^ \/ + / , "" ) . replace ( / ^ m e d i u m \/ ? / , "" ) ;
8+ path = path . replace ( / ^ h t t p s ? : \/ \/ k a p i l l a m b a 4 \. m e d i u m \. c o m \/ ? / i, "" ) ;
9+ const target = `https://kapillamba4.medium.com/${ path } ${ search || "" } ` ;
10+
11+ // Redirect immediately
12+ window . location . replace ( target ) ;
1313
14+ // This return will likely never render due to immediate redirect
1415 return null ;
15-
1616} ;
1717
1818export default MediumRedirect ;
You can’t perform that action at this time.
0 commit comments