Skip to content

Commit 6bf3c81

Browse files
committed
add
1 parent ae456d7 commit 6bf3c81

File tree

4 files changed

+38
-18
lines changed

4 files changed

+38
-18
lines changed

.nojekyll

Whitespace-only changes.

next.config.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ const nextConfig = {
99
hostname: '**', // Adjust this for production
1010
},
1111
],
12+
unoptimized: true, // Required for static export
1213
},
13-
output: 'standalone',
14-
// Helps with consistent routing
14+
output: 'export',
15+
basePath: '/golangmastery.github.io',
16+
assetPrefix: '/golangmastery.github.io/',
1517
trailingSlash: true,
1618

1719
// Disable typescript checking temporarily
@@ -24,20 +26,6 @@ const nextConfig = {
2426
serverComponentsExternalPackages: ['@prisma/client', 'bcryptjs'],
2527
},
2628

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-
4129
webpack: (config) => {
4230
config.resolve.fallback = { fs: false };
4331
return config;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"scripts": {
77
"dev": "next dev",
88
"build": "next build",
9-
"export": "next export",
109
"start": "next start",
1110
"lint": "next lint",
1211
"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"
1414
},
1515
"repository": {
1616
"type": "git",

pages/404.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
}

0 commit comments

Comments
 (0)