File tree Expand file tree Collapse file tree 4 files changed +39
-4
lines changed Expand file tree Collapse file tree 4 files changed +39
-4
lines changed Original file line number Diff line number Diff line change 1+
Original file line number Diff line number Diff line change @@ -10,8 +10,9 @@ const nextConfig = {
1010 } ,
1111 ] ,
1212 } ,
13- output : 'standalone' ,
14- // Helps with consistent routing
13+ output : 'export' ,
14+ basePath : '/golangmastery.github.io' ,
15+ assetPrefix : '/golangmastery.github.io/' ,
1516 trailingSlash : true ,
1617
1718 // Disable typescript checking temporarily
Original file line number Diff line number Diff line change 66 "scripts" : {
77 "dev" : " next dev" ,
88 "build" : " next build" ,
9- "export" : " next export" ,
9+ "export" : " next build && next export" ,
1010 "start" : " next start" ,
1111 "lint" : " next lint" ,
1212 "analyze" : " cross-env ANALYZE=true next build" ,
13- "analyze-bundle" : " node analyze-bundle.js"
13+ "analyze-bundle" : " node analyze-bundle.js" ,
14+ "deploy" : " npm run build && touch out/.nojekyll && git add out/ && git commit -m \" Deploy to GitHub Pages\" && git subtree push --prefix out origin gh-pages"
1415 },
1516 "repository" : {
1617 "type" : " git" ,
Original file line number Diff line number Diff line change 1+ import { useEffect } from 'react' ;
2+ import { useRouter } from 'next/router' ;
3+
4+ export default function Custom404 ( ) {
5+ const router = useRouter ( ) ;
6+
7+ useEffect ( ( ) => {
8+ // Get the current path
9+ const path = window . location . pathname ;
10+
11+ // Remove the base path if it exists
12+ const cleanPath = path . replace ( '/golangmastery.github.io' , '' ) ;
13+
14+ // Try to redirect to the correct path
15+ if ( cleanPath !== path ) {
16+ router . push ( cleanPath ) ;
17+ } else {
18+ // If we're already at the clean path, redirect to home
19+ router . push ( '/' ) ;
20+ }
21+ } , [ router ] ) ;
22+
23+ return (
24+ < div className = "min-h-screen flex items-center justify-center bg-gray-50" >
25+ < div className = "text-center" >
26+ < h1 className = "text-4xl font-bold text-gray-900 mb-4" > 404 - Page Not Found</ h1 >
27+ < p className = "text-gray-600 mb-8" > Redirecting you to the correct page...</ p >
28+ < div className = "animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-blue-500 mx-auto" > </ div >
29+ </ div >
30+ </ div >
31+ ) ;
32+ }
You can’t perform that action at this time.
0 commit comments