-
Notifications
You must be signed in to change notification settings - Fork 3
/
lib.typ
189 lines (170 loc) · 3.64 KB
/
lib.typ
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#import "@preview/fontawesome:0.5.0": *
#let _cv-line(left, right, ..args) = {
set block(below: 0pt)
table(
columns: (1fr, 5fr),
stroke: none,
..args.named(),
left,
right,
)
}
#let moderncv-blue = rgb("#3973AF")
#let _header(
title: [],
subtitle: [],
socials: (:),
) = {
let titleStack = stack(
dir: ttb,
spacing: 1em,
text(size: 30pt, title),
text(size: 20pt, subtitle),
)
let social(icon, link_prefix, username) = [
#fa-icon(icon) #link(link_prefix + username)[#username]
]
let custom-social(icon, dest, body) = [
#fa-icon(icon) #link(dest, body)
]
let socialsDict = (
// key: (faIcon, linkPrefix)
phone: ("phone", "tel:"),
email: ("envelope", "mailto:"),
github: ("github", "https://github.com/"),
linkedin: ("linkedin", "https://linkedin.com/in/"),
x: ("x-twitter", "https://twitter.com/"),
bluesky: ("bluesky", "https://bsky.app/profile/"),
)
let socialsList = ()
for entry in socials {
assert(type(entry) == array, message: "Invalid social entry type.")
assert(entry.len() == 2, message: "Invalid social entry length.")
let (key, value) = entry
if type(value) == str {
if key not in socialsDict {
panic("Unknown social key: " + key)
}
let (icon, linkPrefix) = socialsDict.at(key)
socialsList.push(social(icon, linkPrefix, value))
} else if type(value) == array {
assert(value.len() == 3, message: "Invalid social entry: " + key)
let (icon, dest, body) = value
socialsList.push(custom-social(icon, dest, body))
} else {
panic("Invalid social entry: " + entry)
}
}
let socialStack = stack(
dir: ttb,
spacing: 0.5em,
..socialsList,
)
stack(
dir: ltr,
titleStack,
align(
right + top,
socialStack,
),
)
}
#let moderner-cv(
name: [],
subtitle: [CV],
social: (:),
color: moderncv-blue,
lang: "en",
font: ("New Computer Modern"),
show-footer: true,
body,
) = [
#set page(
paper: "a4",
margin: (
top: 10mm,
bottom: 15mm,
left: 15mm,
right: 15mm,
),
)
#set text(
font: font,
lang: lang,
)
#show heading: it => {
set text(weight: "regular")
set text(color)
set block(above: 0pt)
_cv-line(
[],
[#it.body],
)
}
#show heading.where(level: 1): it => {
set text(weight: "regular")
set text(color)
_cv-line(
align: horizon,
[#box(fill: color, width: 28mm, height: 0.25em)],
[#it.body],
)
}
#_header(title: name, subtitle: subtitle, socials: social)
#body
#if show-footer [
#v(1fr, weak: false)
#name\
#datetime.today().display("[month repr:long] [day], [year]")
]
]
#let cv-line(left-side, right-side) = {
_cv-line(
align(right, left-side),
par(right-side, justify: true),
)
}
#let cv-entry(
date: [],
title: [],
employer: [],
..description,
) = {
let elements = (
strong(title),
emph(employer),
..description.pos(),
)
cv-line(
date,
elements.join(", "),
)
}
#let cv-language(name: [], level: [], comment: []) = {
_cv-line(
align(right, name),
stack(dir: ltr, level, align(right, emph(comment))),
)
}
#let cv-double-item(left-1, right-1, left-2, right-2) = {
set block(below: 0pt)
table(
columns: (1fr, 2fr, 1fr, 2fr),
stroke: none,
align(right, left-1), right-1, align(right, left-2), right-2,
)
}
#let cv-list-item(item) = {
_cv-line(
[],
list(item),
)
}
#let cv-list-double-item(item1, item2) = {
set block(below: 0pt)
table(
columns: (1fr, 2.5fr, 2.5fr),
stroke: none,
[], list(item1), list(item2),
)
}