Skip to content

Commit c18de16

Browse files
committed
fix: adapt to serving from non-root
1 parent ec91250 commit c18de16

6 files changed

Lines changed: 9 additions & 8 deletions

File tree

astro.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import react from '@astrojs/react';
33
import tailwindcss from '@tailwindcss/vite';
44

55
export default defineConfig({
6-
site: 'https://cookielab.github.io/blog-devdrift/',
6+
site: 'https://cookielab.github.io',
7+
base: '/blog-devdrift',
78
output: 'static',
89
integrations: [react()],
910
vite: {

src/components/CategoryTrendChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function CategoryTrendChart() {
2828
const canvasRef = useRef<HTMLCanvasElement>(null);
2929

3030
useEffect(() => {
31-
fetch('/data/skills-timeline.json')
31+
fetch(`${import.meta.env.BASE_URL}data/skills-timeline.json`)
3232
.then(r => r.json())
3333
.then(data => {
3434
const ctx = canvasRef.current?.getContext('2d');

src/components/ComplexityChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function ComplexityChart() {
2424
const canvasRef = useRef<HTMLCanvasElement>(null);
2525

2626
useEffect(() => {
27-
fetch('/data/complexity-data.json')
27+
fetch(`${import.meta.env.BASE_URL}data/complexity-data.json`)
2828
.then(r => r.json())
2929
.then(data => {
3030
const ctx = canvasRef.current?.getContext('2d');

src/components/PopulationChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function PopulationChart() {
1717
const canvasRef = useRef<HTMLCanvasElement>(null);
1818

1919
useEffect(() => {
20-
fetch('/data/population-data.json')
20+
fetch(`${import.meta.env.BASE_URL}data/population-data.json`)
2121
.then(r => r.json())
2222
.then(data => {
2323
const ctx = canvasRef.current?.getContext('2d');

src/components/SkillFilters.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function SkillFilters() {
3232
const [userFilteredCategories, setUserFilteredCategories] = useState(false);
3333

3434
useEffect(() => {
35-
fetch('/data/skills-timeline.json')
35+
fetch(`${import.meta.env.BASE_URL}data/skills-timeline.json`)
3636
.then(r => r.json())
3737
.then(data => {
3838
setSkillsList(data.skills.map((s: any) => ({ name: s.name, category: s.category })));

src/components/SkillsChart.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ export default function SkillsChart({ activeCategories, hiddenSkills }: SkillsCh
7272

7373
useEffect(() => {
7474
Promise.all([
75-
fetch('/data/skills-timeline.json').then(r => r.json()),
76-
fetch('/data/categories.json').then(r => r.json()),
77-
fetch('/data/key-events.json').then(r => r.json()),
75+
fetch(`${import.meta.env.BASE_URL}data/skills-timeline.json`).then(r => r.json()),
76+
fetch(`${import.meta.env.BASE_URL}data/categories.json`).then(r => r.json()),
77+
fetch(`${import.meta.env.BASE_URL}data/key-events.json`).then(r => r.json()),
7878
]).then(([skillData, catData, eventsData]) => {
7979
setSkills(skillData.skills);
8080
setCategories(catData);

0 commit comments

Comments
 (0)