-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcv.tsx
165 lines (156 loc) · 4.32 KB
/
cv.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
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 = (
<View style={tw("w-full mt-4")}>
<View style={tw("w-full border-slate-50 border-b-[.2px]")}></View>
</View>
);
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 = () => (
<Document
title="CV"
author={data.name}
subject="My professional resume"
creator={`${data.name} with react-pdf`}
producer={`${data.name} with react-pdf`}
keywords={`${data.name} ${data.title}`}
>
<Page
size="A4"
style={tw(
"w-full h-full text-slate-50 bg-gray-900 flex flex-col p-12 text-base"
)}
>
<View style={tw("text-center border-2 border-slate-50 rounded-full")}>
<Text style={tw("text-5xl")}>{data.name}</Text>
<Text>{data.title}</Text>
<View
style={tw("flex flex-row gap-4 w-full text-sm justify-center p-4")}
>
{data.github && (
<SvgLink
text="GitHub"
href={`https://github.com/${data.github}`}
icon={svg.github as any}
/>
)}
{data.upwork && (
<SvgLink
text="Upwork"
href={`https://www.upwork.com/freelancers/${data.upwork}`}
icon={svg.link as any}
/>
)}
<SvgLink
text={data.email}
href={`mailto:${data.email}`}
icon={svg.email as any}
/>
{data.phone && (
<SvgLink
text={data.phone}
href={`tel:${data.phone}`}
icon={svg.phone as any}
/>
)}
{data.website && (
<SvgLink
text={data.website}
href={`https://${data.website}`}
icon={svg.globe as any}
/>
)}
</View>
</View>
<View style={tw("my-auto")}>
{divider}
<Text style={tw("text-2xl mt-2 text-violet-500")}>Experience</Text>
{data.experience?.map((e, i) => (
<Experience
key={i}
to={e.to}
from={e.from}
links={e.links}
company={e.company}
location={e.location}
position={e.position}
feedback={e.feedback}
description={e.description}
/>
))}
{divider}
<Text style={tw("text-2xl mt-2 text-violet-500")}>Education</Text>
{data.education?.map((e, i) => (
<Education
key={i}
to={e.to}
from={e.from}
links={e.links}
institution={e.institution}
location={e.location}
field={e.field}
degree={e.degree}
summary={e.summary}
/>
))}
{divider}
<Text style={tw("text-2xl mt-2 text-violet-500")}>Certificates</Text>
{data.certificates?.map((c, i) => (
<Certificate
key={i}
date={c.date}
links={c.links}
name={c.name}
description={c.description}
issuer={c.issuer}
/>
))}
</View>
</Page>
</Document>
);
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(<Cv />, `${outDir}/${pname}.pdf`);