Skip to content

Commit 10e697f

Browse files
committed
Enhance project features and styling
- Updated `package.json` to include a new script for copying `404.html` for GitHub Pages support and added `react-syntax-highlighter` as a dependency. - Introduced a new `copy-404.js` script to facilitate SPA routing on GitHub Pages. - Added a `Projects` page to display GitHub projects with enhanced styling in `index.css`. - Implemented syntax highlighting in the `Post` component using `react-syntax-highlighter`. - Created new markdown posts on CQRS and DDD with Clean Architecture for better content coverage. - Refactored `Layout` to include a link to the new `Projects` page.
1 parent 4c7ec78 commit 10e697f

14 files changed

+807
-53
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "node scripts/generate-posts.js && vite",
8-
"build": "node scripts/generate-posts.js && tsc -b && vite build",
8+
"build": "node scripts/generate-posts.js && tsc -b && vite build && node scripts/copy-404.js",
99
"lint": "eslint .",
1010
"preview": "vite preview"
1111
},
@@ -15,6 +15,7 @@
1515
"react-dom": "^19.2.0",
1616
"react-markdown": "^10.1.0",
1717
"react-router-dom": "^7.13.0",
18+
"react-syntax-highlighter": "^16.1.0",
1819
"remark-gfm": "^4.0.1"
1920
},
2021
"devDependencies": {

pnpm-lock.yaml

Lines changed: 95 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/copy-404.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copy dist/index.html to dist/404.html so GitHub Pages serves the SPA
3+
* for any path (e.g. /posts, /post/slug). The server returns 404.html for
4+
* unknown routes, and the React app loads and handles the URL.
5+
*/
6+
import fs from 'fs';
7+
import path from 'path';
8+
import { fileURLToPath } from 'url';
9+
10+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
11+
const dist = path.join(__dirname, '..', 'dist');
12+
const indexHtml = path.join(dist, 'index.html');
13+
const notFoundHtml = path.join(dist, '404.html');
14+
15+
if (!fs.existsSync(indexHtml)) {
16+
console.error('dist/index.html not found. Run the build first.');
17+
process.exit(1);
18+
}
19+
fs.copyFileSync(indexHtml, notFoundHtml);
20+
console.log('Copied index.html to 404.html for GitHub Pages SPA routing.');

src/components/Layout.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Outlet, NavLink } from 'react-router-dom';
2-
import { Home, Newspaper, Github } from 'lucide-react';
2+
import { Home, Newspaper, FolderGit2, Github } from 'lucide-react';
33
import profileData from '../content/profile.json';
44

55
const profile = profileData as { name: string };
@@ -31,15 +31,10 @@ export default function Layout() {
3131
<Newspaper size={18} aria-hidden />
3232
<span>Posts</span>
3333
</NavLink>
34-
<a
35-
href="https://github.com/vicheanath/vicheanath.github.io"
36-
className="nav__link nav__link--external"
37-
target="_blank"
38-
rel="noopener noreferrer"
39-
>
40-
<Github size={18} aria-hidden />
41-
<span>GitHub</span>
42-
</a>
34+
<NavLink to="/projects" className="nav__link">
35+
<FolderGit2 size={18} aria-hidden />
36+
<span>Projects</span>
37+
</NavLink>
4338
</nav>
4439
</header>
4540
<main className="main" id="main">

0 commit comments

Comments
 (0)