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