More optimizations
All checks were successful
Docker Deploy / build-and-push (push) Successful in 5m6s
All checks were successful
Docker Deploy / build-and-push (push) Successful in 5m6s
This commit is contained in:
@@ -1,94 +1,10 @@
|
||||
import type { APIRoute } from "astro";
|
||||
import { config } from "../../../config";
|
||||
import type { ResumeData } from "../../../types";
|
||||
import * as TOML from "@iarna/toml";
|
||||
import { renderToStream } from "@react-pdf/renderer";
|
||||
import { ResumeDocument } from "../../../pdf/ResumeDocument";
|
||||
import { mdiEmail, mdiPhone, mdiDownload, mdiLink } from "@mdi/js";
|
||||
import * as simpleIcons from "simple-icons";
|
||||
|
||||
function getSimpleIconPath(network: string): string {
|
||||
try {
|
||||
const slug = network.toLowerCase().normalize("NFKD").replace(/[^\w]/g, "");
|
||||
const iconKey = `si${slug.charAt(0).toUpperCase()}${slug.slice(1)}`;
|
||||
|
||||
const icon = (simpleIcons as any)[iconKey];
|
||||
return icon ? icon.path : "";
|
||||
} catch (error) {
|
||||
console.warn(`Error finding icon for network: ${network}`, error);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function getMdiIconPath(iconName: string): string {
|
||||
const iconMap: { [key: string]: string } = {
|
||||
"mdi:email": mdiEmail,
|
||||
"mdi:phone": mdiPhone,
|
||||
"mdi:download": mdiDownload,
|
||||
"mdi:link": mdiLink,
|
||||
};
|
||||
return iconMap[iconName] || "";
|
||||
}
|
||||
|
||||
interface ResumeData {
|
||||
basics: {
|
||||
name: string;
|
||||
email: string;
|
||||
phone?: string;
|
||||
website?: string;
|
||||
profiles: {
|
||||
network: string;
|
||||
username: string;
|
||||
url: string;
|
||||
}[];
|
||||
};
|
||||
layout?: {
|
||||
left_column?: string[];
|
||||
right_column?: string[];
|
||||
};
|
||||
summary: {
|
||||
content: string;
|
||||
};
|
||||
experience: {
|
||||
company: string;
|
||||
position: string;
|
||||
location: string;
|
||||
date: string;
|
||||
description: string[];
|
||||
url?: string;
|
||||
}[];
|
||||
education: {
|
||||
institution: string;
|
||||
degree: string;
|
||||
field: string;
|
||||
date: string;
|
||||
details?: string[];
|
||||
}[];
|
||||
skills: {
|
||||
name: string;
|
||||
level: number;
|
||||
}[];
|
||||
volunteer: {
|
||||
organization: string;
|
||||
position: string;
|
||||
date: string;
|
||||
}[];
|
||||
awards: {
|
||||
title: string;
|
||||
organization: string;
|
||||
date: string;
|
||||
description?: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
const fetchProfileIcons = (profiles: any[]) => {
|
||||
const profileIcons: { [key: string]: string } = {};
|
||||
if (profiles) {
|
||||
for (const profile of profiles) {
|
||||
profileIcons[profile.network] = getSimpleIconPath(profile.network);
|
||||
}
|
||||
}
|
||||
return profileIcons;
|
||||
};
|
||||
import { getMdiIconPath, fetchProfileIcons } from "../../../utils/icons";
|
||||
|
||||
const generatePDF = async (data: ResumeData) => {
|
||||
const resumeConfig = config.resumeConfig;
|
||||
|
||||
Reference in New Issue
Block a user