Fixed resume rendering (was bad)
This commit is contained in:
@ -1,7 +1,5 @@
|
|||||||
---
|
---
|
||||||
import { Icon } from 'astro-icon/components';
|
import { Icon } from 'astro-icon/components';
|
||||||
import { readFile } from 'node:fs/promises';
|
|
||||||
import { join } from 'node:path';
|
|
||||||
import Layout from '../layouts/Layout.astro';
|
import Layout from '../layouts/Layout.astro';
|
||||||
import SkillsSection from '../components/SkillsSection.tsx';
|
import SkillsSection from '../components/SkillsSection.tsx';
|
||||||
import '../styles/global.css';
|
import '../styles/global.css';
|
||||||
@ -26,15 +24,17 @@ let resumeData: ResumeData | undefined = undefined;
|
|||||||
let fetchError: string | null = null;
|
let fetchError: string | null = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let resumeJson: string;
|
// Get the base URL for the current request
|
||||||
|
const baseUrl = Astro.url.origin;
|
||||||
|
|
||||||
try {
|
// Fetch the JSON file from the public directory
|
||||||
resumeJson = await readFile(join(process.cwd(), 'public', 'files', 'resume.json'), 'utf-8');
|
const response = await fetch(`${baseUrl}/files/resume.json`);
|
||||||
} catch (err) {
|
|
||||||
resumeJson = await readFile('/Users/atridad/Downloads/resume.json', 'utf-8');
|
if (!response.ok) {
|
||||||
|
throw new Error(`Failed to fetch resume: ${response.status} ${response.statusText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
resumeData = JSON.parse(resumeJson);
|
resumeData = await response.json();
|
||||||
|
|
||||||
if (resumeData && resumeData.sections && resumeData.sections.skills) {
|
if (resumeData && resumeData.sections && resumeData.sections.skills) {
|
||||||
const skillsSection = resumeData.sections.skills;
|
const skillsSection = resumeData.sections.skills;
|
||||||
@ -46,8 +46,8 @@ try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error processing resume data:", error);
|
console.error("Error loading resume data:", error);
|
||||||
fetchError = "An error occurred while processing resume data. Please make sure the resume.json file is in the correct location.";
|
fetchError = "Unable to load resume data. Please make sure the resume.json file exists in /public/files/";
|
||||||
resumeData = undefined;
|
resumeData = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user