File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="utf-8 ">
5+ < title > Redirecting</ title >
6+ < script type ="text/javascript ">
7+ // Single Page Apps for GitHub Pages
8+ // Redirect to index.html with path preserved
9+ var pathSegmentsToKeep = 0 ;
10+ var l = window . location ;
11+ l . replace (
12+ l . protocol + '//' + l . hostname + ( l . port ? ':' + l . port : '' ) +
13+ '/index.html?p=/' + l . pathname . slice ( 1 ) . split ( '/' ) . slice ( pathSegmentsToKeep ) . join ( '/' ) . replace ( / & / g, '~and~' ) +
14+ ( l . search ? '&q=' + l . search . slice ( 1 ) . replace ( / & / g, '~and~' ) : '' ) +
15+ l . hash
16+ ) ;
17+ </ script >
18+ </ head >
19+ < body >
20+ </ body >
21+ </ html >
Original file line number Diff line number Diff line change 11import { FunctionComponent , PropsWithChildren , useEffect } from 'react' ;
2- import { useSearchParams } from 'react-router-dom' ;
2+ import { useSearchParams , useNavigate } from 'react-router-dom' ;
33import { projectsStore } from 'src/shared/stores' ;
44import { observer } from 'mobx-react-lite' ;
55
66const ApplyQueryParams : FunctionComponent < PropsWithChildren > = ( { children } ) => {
77 const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
8+ const navigate = useNavigate ( ) ;
89
910 useEffect ( ( ) => {
11+ // Handle GitHub Pages 404 redirect for SPA routing
12+ const pathParam = searchParams . get ( 'p' ) ;
13+ if ( pathParam !== null ) {
14+ // Decode the saved path and navigate to it
15+ const decodedPath = pathParam . replace ( / ~ a n d ~ / g, '&' ) ;
16+ searchParams . delete ( 'p' ) ;
17+ setSearchParams ( searchParams ) ;
18+ navigate ( decodedPath ) ;
19+ return ;
20+ }
21+
1022 const projectId = searchParams . get ( 'project_id' ) ;
1123 if ( projectId !== null ) {
1224 searchParams . delete ( 'project_id' ) ;
You can’t perform that action at this time.
0 commit comments