import { Page, Text, View, Document } from "@react-pdf/renderer"; import ReactPDF from "@react-pdf/renderer"; import fs from "fs"; import { svg, tw } from "./theme/lib"; import SvgLink from "./theme/link"; import Experience, { Exp } from "./theme/experience"; import Education, { Edu } from "./theme/education"; import Certificate, { Cert } from "./theme/certificate"; const divider = ( ); type CV = { name: string; description: string; title: string; email: string; github?: string; website?: string; upwork?: string; phone?: string; experience?: Exp[]; education?: Edu[]; certificates?: Cert[]; }; let data: CV = {} as CV; const Cv = () => ( {data.name} {data.title} {data.github && ( )} {data.upwork && ( )} {data.phone && ( )} {data.website && ( )} {divider} Experience {data.experience?.map((e, i) => ( ))} {divider} Education {data.education?.map((e, i) => ( ))} {divider} Certificates {data.certificates?.map((c, i) => ( ))} ); const parseData = () => { const d = fs.readFileSync("./cv.json", { encoding: "utf8" }); const json: CV = JSON.parse(d); json.experience = json.experience?.map((e) => ({ ...e, from: new Date(e.from), to: new Date(e.to), })); json.education = json.education?.map((e) => ({ ...e, from: new Date(e.from), to: new Date(e.to), })); json.certificates = json.certificates?.map((c) => ({ ...c, date: new Date(c.date), })); data = json; }; const outDir = process.env.out || "./"; const pname = process.env.pname || "cv"; if (!fs.existsSync(outDir)) { fs.mkdirSync(outDir, { recursive: true }); } parseData(); ReactPDF.render(, `${outDir}/${pname}.pdf`);