Skip to content

Commit b600ef4

Browse files
committed
feat: publish to github pages
1 parent 313a305 commit b600ef4

File tree

9 files changed

+85
-12
lines changed

9 files changed

+85
-12
lines changed

.github/workflows/publish.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: true
16+
17+
jobs:
18+
deploy:
19+
environment:
20+
name: github-pages
21+
url: ${{ steps.deployment.outputs.page_url }}
22+
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- uses: actions/setup-node@v3
29+
with:
30+
node-version: 22.x
31+
cache: "npm"
32+
33+
- name: Restore
34+
run: npm ci
35+
36+
- name: Test
37+
run: npm run lint
38+
39+
- name: Build
40+
run: npm run build
41+
42+
- name: Setup Pages
43+
uses: actions/configure-pages@v5
44+
45+
- name: Upload artifact
46+
uses: actions/upload-pages-artifact@v3
47+
with:
48+
path: "dist"
49+
50+
- name: Deploy to GitHub Pages
51+
id: deployment
52+
uses: actions/deploy-pages@v4

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Binary Timer is a simple countdown timer that counts down in binary.
44

5-
Available online at [https://binarytimer.surge.sh](https://binarytimer.surge.sh)
5+
Available online at [https://kungfux.github.io/binarytimer/](https://kungfux.github.io/binarytimer/)
66

77
![screenshot](public/screenshot-wide.png)
88

index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
<meta charset="UTF-8" />
66
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
77
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8-
<meta name="google-site-verification" content="DuybeW01gi4SeBHy7YyqfLYOfQ82DNm-heBEhjprUVc" />
98
<meta name="description"
109
content="Binary Timer Countdown - A Unique Way to Track Time in Binary!
1110
This interactive tool lets you visualize countdowns in binary, making it perfect for tech enthusiasts, programmers, and learners. Whether you're exploring binary concepts, teaching coding fundamentals, or simply fascinated by unique timers, our binary countdown tool combines education and functionality. Learn, teach, and enjoy the simplicity of binary time tracking today!">
1211
<meta name="author" content="kungfux">
13-
<link rel="canonical" href="https://binarytimer.surge.sh/">
12+
<link rel="canonical" href="https://kungfux.github.io/binarytimer/">
1413
<title>Binary Timer</title>
1514
</head>
1615
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ZX3L2JT8RY"></script>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"private": true,
44
"version": "0.0.0",
55
"type": "module",
6+
"homepage": "https://kungfux.github.io/binarytimer",
67
"scripts": {
78
"dev": "vite",
89
"build": "tsc -b && vite build",
9-
"publish": "surge ./dist binarytimer.surge.sh",
1010
"lint": "eslint .",
1111
"preview": "vite preview"
1212
},

src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Routes, Route, useLocation } from "react-router-dom";
22

3+
import routes from "./routes";
34
import TimerSetup from "./pages/TimerSetup.page";
45
import TimerCountdown from "./pages/TimerCountdown.page";
56
import Footer from "./components/Footer.component";
@@ -20,7 +21,7 @@ function App() {
2021
</div>
2122
<Routes>
2223
<Route
23-
path="/"
24+
path={routes.root.path}
2425
element={timeParam ? <TimerCountdown /> : <TimerSetup />}
2526
/>
2627
</Routes>

src/main.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { BrowserRouter } from "react-router-dom";
44

55
import "./index.css";
66
import App from "./App.tsx";
7+
import routes from "./routes.ts";
78

89
createRoot(document.getElementById("root")!).render(
910
<StrictMode>
10-
<BrowserRouter>
11+
<BrowserRouter basename={routes.base}>
1112
<App />
1213
</BrowserRouter>
1314
</StrictMode>

src/pages/TimerCountdown.page.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { createRef, useCallback, useMemo } from "react";
22
import { useState, useEffect } from "react";
33
import { useLocation, useNavigate } from "react-router-dom";
44

5-
import { Button, ButtonType } from "../components/Button.component";
5+
import routes from "../routes";
66
import BitButton from "../components/BitButton.component";
77
import BitCounter from "../BitCounter";
8+
import { Button, ButtonType } from "../components/Button.component";
89
import { useMuteContext } from "../hooks/useMuteContext.hook";
910

1011
function TimerCountdown() {
@@ -44,11 +45,11 @@ function TimerCountdown() {
4445
.play()
4546
.then(() => {
4647
audio.onended = () => {
47-
navigate("/");
48+
navigate(routes.root.path);
4849
};
4950
})
5051
.catch(() => {
51-
navigate("/");
52+
navigate(routes.root.path);
5253
});
5354
}, [navigate]);
5455

@@ -84,7 +85,7 @@ function TimerCountdown() {
8485
<Button
8586
type={ButtonType.Primary}
8687
text="🛑 Stop"
87-
onClick={() => navigate("/")}
88+
onClick={() => navigate(routes.root.path)}
8889
/>
8990
),
9091
[navigate]
@@ -106,8 +107,18 @@ function TimerCountdown() {
106107

107108
return (
108109
<>
109-
<audio id="bee" src="bee.mp3" preload="auto" muted={isMuted} />
110-
<audio id="doo" src="doo.mp3" preload="auto" muted={isMuted} />
110+
<audio
111+
id="bee"
112+
src={`${routes.base}/bee.mp3`}
113+
preload="auto"
114+
muted={isMuted}
115+
/>
116+
<audio
117+
id="doo"
118+
src={`${routes.base}/doo.mp3`}
119+
preload="auto"
120+
muted={isMuted}
121+
/>
111122
<div className="flex flex-col items-center justify-center text-center">
112123
<div className="flex flex-col items-center justify-center text-center">
113124
<h1 className="text-5xl uppercase mb-8">Please stand by</h1>

src/routes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const routes = {
2+
base: '/binarytimer/',
3+
root: {
4+
path: '/',
5+
},
6+
}
7+
8+
export default routes;

vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import react from '@vitejs/plugin-react'
33
import { VitePWA } from 'vite-plugin-pwa';
44

55
export default defineConfig({
6+
base: '/binarytimer/',
67
plugins: [react(),
78
VitePWA({
89
registerType: 'autoUpdate',

0 commit comments

Comments
 (0)