Skip to content

Commit 45d5604

Browse files
Merge pull request #2 from AlessandroFlati/claude/japanese-vocab-matcher-011CUv6yn8vCn3LYkdUKvqVr
Fix asset paths for GitHub Pages deployment
2 parents dad8d18 + 3a440c6 commit 45d5604

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/services/dataLoader.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77

88
import storage from './storage';
99

10+
// Get the base URL from Vite configuration for correct asset paths
11+
const BASE_URL = import.meta.env.BASE_URL;
12+
1013
/**
1114
* Load vocabulary data from JSON file
1215
*/
1316
export const loadVocabulary = async () => {
1417
try {
15-
const response = await fetch('/data/vocabulary.json');
18+
const response = await fetch(`${BASE_URL}data/vocabulary.json`);
1619
if (!response.ok) {
1720
throw new Error(`Failed to load vocabulary: ${response.statusText}`);
1821
}
@@ -29,7 +32,7 @@ export const loadVocabulary = async () => {
2932
*/
3033
export const loadCollocations = async () => {
3134
try {
32-
const response = await fetch('/data/collocations_complete.json');
35+
const response = await fetch(`${BASE_URL}data/collocations_complete.json`);
3336
if (!response.ok) {
3437
throw new Error(`Failed to load collocations: ${response.statusText}`);
3538
}
@@ -48,7 +51,7 @@ export const loadHints = async () => {
4851
try {
4952
// Add cache-busting parameter to force reload of updated hints
5053
const cacheBuster = Date.now();
51-
const response = await fetch(`/data/collocation_hints.json?v=${cacheBuster}`);
54+
const response = await fetch(`${BASE_URL}data/collocation_hints.json?v=${cacheBuster}`);
5255
if (!response.ok) {
5356
throw new Error(`Failed to load hints: ${response.statusText}`);
5457
}
@@ -152,7 +155,7 @@ export const loadReverseHints = async () => {
152155
try {
153156
// Add cache-busting parameter to force reload of updated hints
154157
const cacheBuster = Date.now();
155-
const response = await fetch(`/data/reverse_hints.json?v=${cacheBuster}`);
158+
const response = await fetch(`${BASE_URL}data/reverse_hints.json?v=${cacheBuster}`);
156159
if (!response.ok) {
157160
console.warn('Reverse hints not found, will use fallback');
158161
return null;

0 commit comments

Comments
 (0)