-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
115 lines (94 loc) · 3.13 KB
/
index.js
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
import { writeFileSync } from "fs";
import fs from "fs";
const cv = JSON.parse(fs.readFileSync("./cv.json", "utf-8"));
generate_html("fr", "./fr.html");
generate_html("en", "./en.html");
function generate_html(lang, page_name) {
const education = add_section(cv[0], lang);
const experience = add_section(cv[1], lang);
const skills = add_section(cv[2], lang);
const publications = add_section(cv[3], lang);
const title = lang == "fr" ? "Docteur en automatique" : "Control systems engineer (PhD)";
let html = `
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Louis CASSANY</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/aaaakshat/cm-web-fonts@latest/fonts.css">
<link rel="stylesheet" href="./styles.css">
</head>
<style>
@media print {
@page {
size: A4 portrait;
margin: 1cm 0cm;
}
.print {
display: revert;
}
.no-print {
display: none;
}
/* h1,
h2,
h3,
h4,
caption {
page-break-after: avoid;
} */
}
</style>
<body>
<div class="flex justify-center items-center print:mt-0 px-4 sm:px-8">
<div class="flex sm:space-x-16 justify-between w-full sm:justify-center">
<img src="./photo_cv.jpg" class="h-24 sm:h-36 rounded-lg shadow-2xl my-auto" />
<div class="flex flex-col items-end text-right justify-start print:justify-start">
<span class="text-xl sm:text-4xl"> Louis CASSANY </span>
<span class="text-md sm:text-xl text-blue-900 font-bold "> ${title} </span>
<span> [email protected] </span>
<span> (+33) 6 45 32 03 41</span>
</div>
</div>
</div>
<div class="print:columns-2 lg:columns-2 px-4 sm:px-8 xl:w-9/12 mx-auto pb-8 xl:text-xl" id="cv">
${education}
${experience}
${skills}
${publications}
</div>
</body>
</html>`;
writeFileSync(page_name, html);
}
function add_section(section, lang) {
let html = `<div>`;
let flag = false;
for (const item of section.items) {
html += `<div class="px-2 flex flex-col w-full my-2 md:px-8 item">`;
if (!flag) {
html += `<h1 class="lg:text-2xl text-2xl font-bold">${section.title[lang]}</h1>`;
// html += `<hr class="h-[3px] bg-blue-900 mb-4 border-0"/>`;
flag = true;
}
if (item.date || item.title)
html += `<div class="flex justify-between items-center">
<h2 class="lg:text-xl text-lg font-bold text-blue-900">${item.title[lang]}</h2>
${item.date ? `<span class="text-sm whitespace-nowrap">${item.date[lang]}</span>` : ""}
</div>`;
if (item.location) html += `<div class="font-bold">${item.location[lang]}</div>`;
if (item.subtitle) html += `<div class="whitespace-pre-line">${item.subtitle[lang]}</div>`;
if (item.list) {
html += `<ul class="marker:text-blue-900 list-inside list-disc">`;
for (const listItem of item.list[lang]) {
html += `<li>${listItem}</li>`;
}
html += `</ul>`;
}
html += "</div>";
}
html += `</div>`;
return html;
}