Skip to content

Commit 1dbe2ec

Browse files
committed
automated build process
1 parent 5f9c45c commit 1dbe2ec

2 files changed

Lines changed: 46 additions & 3 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
cache: npm
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Build
29+
run: npm run build
30+
31+
- name: Deploy to gh-pages
32+
uses: peaceiris/actions-gh-pages@v4
33+
with:
34+
github_token: ${{ secrets.GITHUB_TOKEN }}
35+
publish_dir: ./dist
36+
publish_branch: gh-pages
37+
force_orphan: true

src/App.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ const TOOLS = [
2626
{ id: "disclaimer", label: "Disclaimer", glyph: "§", Component: Disclaimer, badge: "legal" },
2727
];
2828

29+
const BASE = import.meta.env.BASE_URL; // "/syskit/" in prod, "/" in dev
30+
2931
function getToolFromPath() {
30-
const id = window.location.pathname.replace(/^\//, "").split("/")[0];
32+
const path = window.location.pathname;
33+
const relative = path.startsWith(BASE) ? path.slice(BASE.length) : path.replace(/^\//, "");
34+
const id = relative.split("/")[0];
3135
return TOOLS.find((t) => t.id === id)?.id ?? "chmod";
3236
}
3337

@@ -74,9 +78,11 @@ export default function App() {
7478
}, [theme]);
7579

7680
useEffect(() => {
77-
const current = window.location.pathname.replace(/^\//, "").split("/")[0];
81+
const path = window.location.pathname;
82+
const relative = path.startsWith(BASE) ? path.slice(BASE.length) : path.replace(/^\//, "");
83+
const current = relative.split("/")[0];
7884
if (current !== activeTool) {
79-
history.pushState({}, "", "/" + activeTool);
85+
history.pushState({}, "", BASE + activeTool);
8086
}
8187
}, [activeTool]);
8288

0 commit comments

Comments
 (0)