Skip to content

Commit 3dd2e49

Browse files
committed
build: build app with hashrouting
1 parent 54581f7 commit 3dd2e49

8 files changed

Lines changed: 214 additions & 167 deletions

File tree

.github/workflows/deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ jobs:
3939
cp -r dist/* temp-portfolio/projects/flashmaster/
4040
cd temp-portfolio
4141
git add .
42-
git commit -m "Deploy updated Flashmaster frontend"
42+
git commit -m "Deploy updated Flashmaster frontend with hash routing"
4343
git push

README.md

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,56 @@
11
# Flashmaster
22

3-
Vibe‑coded on **Replit** with TypeScript & Vite.
3+
A flashcard-based learning application built with TypeScript, React, and Vite. Uses hash-based routing for GitHub Pages compatibility.
44

5-
🔗 Demo: https://usamasadiq.us/projects/flashmaster
5+
🔗 Demo: https://usamasadiq.github.io/projects/flashmaster/
66

7-
# Deploy Instructions
7+
## Development
88

9-
`npm install`
10-
`npm run build`
9+
```bash
10+
npm install
11+
npm run dev
12+
```
1113

12-
Upload dist files. Workflow will deploy to portfolio site automatically.
14+
## Build
15+
16+
```bash
17+
npm install
18+
npm run build
19+
```
20+
21+
## GitHub Pages Deployment
22+
23+
This application is configured to deploy to `usamasadiq.github.io/projects/flashmaster/` with hash-based routing to avoid 404 errors on GitHub Pages.
24+
25+
### Automatic Deployment (Recommended)
26+
27+
1. **Set up GitHub PAT**:
28+
- Create a Personal Access Token with `repo` permissions
29+
- Add it as a secret named `GH_PAT` in this repository (Settings → Secrets and variables → Actions)
30+
31+
2. **Deploy**:
32+
- Push your code to this repository's main branch
33+
- The GitHub Action will automatically build and deploy to `usamasadiq.github.io/projects/flashmaster/`
34+
35+
### Manual Deployment
36+
37+
1. Build the project: `npm run build`
38+
2. Copy the contents of the `dist/` directory to `projects/flashmaster/` in the `usamasadiq.github.io` repository
39+
3. Commit and push the changes to the `usamasadiq.github.io` repository
40+
41+
### Configuration Notes
42+
43+
- **Base Path**: Set to `/projects/flashmaster/` in `vite.config.ts` for the target deployment location
44+
- **Routing**: Uses hash-based routing (`#/flashcard/javascript`) to avoid GitHub Pages 404 errors
45+
- **Target Repository**: `usamasadiq/usamasadiq.github.io`
46+
- **Target Path**: `projects/flashmaster/`
47+
- **Live URL**: `https://usamasadiq.github.io/projects/flashmaster/`
48+
49+
## Features
50+
51+
- Interactive flashcard learning system with hash-based routing for GitHub Pages compatibility
52+
- Multiple technology categories (HTML/CSS, JavaScript, React, TypeScript, Python, Node.js)
53+
- Progress tracking
54+
- Responsive design
55+
- Built with modern web technologies
56+
- Hash routing ensures proper navigation on GitHub Pages (routes like `#/flashcard/javascript`)

client/src/App.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Switch, Route } from "wouter";
1+
import { Switch, Route, Router } from "wouter";
2+
import { useHashLocation } from "wouter/use-hash-location";
23
import { queryClient } from "./lib/queryClient";
34
import { QueryClientProvider } from "@tanstack/react-query";
45
import { Toaster } from "@/components/ui/toaster";
@@ -7,13 +8,15 @@ import Home from "@/pages/home";
78
import Flashcard from "@/pages/flashcard";
89
import NotFound from "@/pages/not-found";
910

10-
function Router() {
11+
function AppRouter() {
1112
return (
12-
<Switch>
13-
<Route path="/" component={Home} />
14-
<Route path="/flashcard/:technology" component={Flashcard} />
15-
<Route component={NotFound} />
16-
</Switch>
13+
<Router hook={useHashLocation}>
14+
<Switch>
15+
<Route path="/" component={Home} />
16+
<Route path="/flashcard/:technology" component={Flashcard} />
17+
<Route component={NotFound} />
18+
</Switch>
19+
</Router>
1720
);
1821
}
1922

@@ -22,7 +25,7 @@ function App() {
2225
<QueryClientProvider client={queryClient}>
2326
<TooltipProvider>
2427
<Toaster />
25-
<Router />
28+
<AppRouter />
2629
</TooltipProvider>
2730
</QueryClientProvider>
2831
);

client/src/components/technology-card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { Card, CardContent } from "@/components/ui/card";
2-
import { useLocation } from "wouter";
2+
import { useHashLocation } from "wouter/use-hash-location";
33

44
interface TechnologyCardProps {
55
technology: string;
66
questionCount: number;
77
}
88

99
export default function TechnologyCard({ technology, questionCount }: TechnologyCardProps) {
10-
const [, setLocation] = useLocation();
10+
const [, setLocation] = useHashLocation();
1111

1212
const handleClick = () => {
1313
setLocation(`/flashcard/${encodeURIComponent(technology)}`);

client/src/pages/flashcard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Button } from "@/components/ui/button";
44
import { Card, CardContent } from "@/components/ui/card";
55
import { ChevronLeft, ChevronRight, Home, HelpCircle } from "lucide-react";
66
import { useState, useEffect, useCallback } from "react";
7-
import { useLocation } from "wouter";
7+
import { useHashLocation } from "wouter/use-hash-location";
88
import FlashcardDisplay from "@/components/flashcard-display";
99
import ProgressBar from "@/components/progress-bar";
1010
import HowToUseModal from "@/components/how-to-use-modal";
@@ -15,7 +15,7 @@ import type { FlashcardData } from "@shared/schema";
1515
export default function Flashcard() {
1616
const { technology: rawTechnology } = useParams<{ technology: string }>();
1717
const technology = rawTechnology ? decodeURIComponent(rawTechnology) : "";
18-
const [, setLocation] = useLocation();
18+
const [, setLocation] = useHashLocation();
1919
const [showModal, setShowModal] = useState(false);
2020

2121
const { data: flashcardData, isLoading } = useQuery<FlashcardData>({

dist/assets/index-B0PTqIws.js

Lines changed: 0 additions & 147 deletions
This file was deleted.

dist/assets/index-EPSlLXeu.js

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

dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" />
6-
<script type="module" crossorigin src="/projects/flashmaster/assets/index-B0PTqIws.js"></script>
6+
<script type="module" crossorigin src="/projects/flashmaster/assets/index-EPSlLXeu.js"></script>
77
<link rel="stylesheet" crossorigin href="/projects/flashmaster/assets/index-Dcn7NiiW.css">
88
</head>
99
<body>

0 commit comments

Comments
 (0)