File tree Expand file tree Collapse file tree 4 files changed +38
-18
lines changed Expand file tree Collapse file tree 4 files changed +38
-18
lines changed Original file line number Diff line number Diff line change @@ -9,9 +9,11 @@ const nextConfig = {
9
9
hostname : '**' , // Adjust this for production
10
10
} ,
11
11
] ,
12
+ unoptimized : true , // Required for static export
12
13
} ,
13
- output : 'standalone' ,
14
- // Helps with consistent routing
14
+ output : 'export' ,
15
+ basePath : '/golangmastery.github.io' ,
16
+ assetPrefix : '/golangmastery.github.io/' ,
15
17
trailingSlash : true ,
16
18
17
19
// Disable typescript checking temporarily
@@ -24,20 +26,6 @@ const nextConfig = {
24
26
serverComponentsExternalPackages : [ '@prisma/client' , 'bcryptjs' ] ,
25
27
} ,
26
28
27
- // Use rewrites for backward compatibility
28
- async rewrites ( ) {
29
- return [
30
- {
31
- source : '/courses/quick-start-with-golang' ,
32
- destination : '/courses/quick-start-with-golang-modules' ,
33
- } ,
34
- {
35
- source : '/courses/quick-start-with-golang/:slug*' ,
36
- destination : '/courses/quick-start-with-golang-modules/:slug*' ,
37
- }
38
- ] ;
39
- } ,
40
-
41
29
webpack : ( config ) => {
42
30
config . resolve . fallback = { fs : false } ;
43
31
return config ;
Original file line number Diff line number Diff line change 6
6
"scripts" : {
7
7
"dev" : " next dev" ,
8
8
"build" : " next build" ,
9
- "export" : " next export" ,
10
9
"start" : " next start" ,
11
10
"lint" : " next lint" ,
12
11
"analyze" : " cross-env ANALYZE=true next build" ,
13
- "analyze-bundle" : " node analyze-bundle.js"
12
+ "analyze-bundle" : " node analyze-bundle.js" ,
13
+ "deploy" : " rm -rf out && next build && touch out/.nojekyll && git add out/ && git commit -m \" Deploy to GitHub Pages\" && git subtree push --prefix out origin gh-pages"
14
14
},
15
15
"repository" : {
16
16
"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
+ // If the path includes the GitHub Pages prefix, clean it and redirect
12
+ if ( path . includes ( '/golangmastery.github.io/' ) ) {
13
+ const cleanPath = path . replace ( '/golangmastery.github.io' , '' ) ;
14
+ router . push ( cleanPath ) ;
15
+ }
16
+ } , [ router ] ) ;
17
+
18
+ return (
19
+ < div className = "min-h-screen flex items-center justify-center bg-gray-50" >
20
+ < div className = "text-center" >
21
+ < h1 className = "text-4xl font-bold text-gray-900 mb-4" > 404 - Page Not Found</ h1 >
22
+ < p className = "text-gray-600 mb-8" > The page you're looking for doesn't exist or has been moved.</ p >
23
+ < button
24
+ onClick = { ( ) => router . push ( '/' ) }
25
+ className = "px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors"
26
+ >
27
+ Go Home
28
+ </ button >
29
+ </ div >
30
+ </ div >
31
+ ) ;
32
+ }
You can’t perform that action at this time.
0 commit comments