-
-
Notifications
You must be signed in to change notification settings - Fork 53
/
lib.typ
821 lines (753 loc) · 20.6 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
#import "@preview/fontawesome:0.5.0": *
#import "@preview/linguify:0.4.1": *
// const color
#let color-darknight = rgb("#131A28")
#let color-darkgray = rgb("#333333")
#let color-gray = rgb("#5d5d5d")
#let default-accent-color = rgb("#262F99")
#let default-location-color = rgb("#333333")
// const icons
#let linkedin-icon = box(
fa-icon("linkedin", fill: color-darknight),
)
#let github-icon = box(
fa-icon("github", fill: color-darknight),
)
#let twitter-icon = box(
fa-icon("twitter", fill: color-darknight),
)
#let google-scholar-icon = box(
fa-icon("google-scholar", fill: color-darknight),
)
#let orcid-icon = box(
fa-icon("orcid", fill: color-darknight),
)
#let phone-icon = box(fa-icon("square-phone", fill: color-darknight))
#let email-icon = box(fa-icon("envelope", fill: color-darknight))
#let birth-icon = box(fa-icon("cake", fill: color-darknight))
#let homepage-icon = box(fa-icon("home", fill: color-darknight))
#let website-icon = box(fa-icon("globe", fill: color-darknight))
/// Helpers
// layout utility
#let __justify_align(left_body, right_body) = {
block[
#left_body
#box(width: 1fr)[
#align(right)[
#right_body
]
]
]
}
#let __justify_align_3(left_body, mid_body, right_body) = {
block[
#box(width: 1fr)[
#align(left)[
#left_body
]
]
#box(width: 1fr)[
#align(center)[
#mid_body
]
]
#box(width: 1fr)[
#align(right)[
#right_body
]
]
]
}
#let __coverletter_footer(author, language, date, lang_data) = {
set text(
fill: gray,
size: 8pt,
)
__justify_align_3[
#smallcaps[#date]
][
#smallcaps[
#if language == "zh" or language == "ja" [
#author.firstname#author.lastname
] else [
#author.firstname#sym.space#author.lastname
]
#sym.dot.c
#linguify("cover-letter", from: lang_data)
]
][
#context {
counter(page).display()
}
]
}
#let __resume_footer(author, language, lang_data, date) = {
set text(
fill: gray,
size: 8pt,
)
__justify_align_3[
#smallcaps[#date]
][
#smallcaps[
#if language == "zh" or language == "ja" [
#author.firstname#author.lastname
] else [
#author.firstname#sym.space#author.lastname
]
#sym.dot.c
#linguify("resume", from: lang_data)
]
][
#context {
counter(page).display()
}
]
}
/// Show a link with an icon, specifically for Github projects
/// *Example*
/// #example(`resume.github-link("DeveloperPaul123/awesome-resume")`)
/// - github-path (string): The path to the Github project (e.g. "DeveloperPaul123/awesome-resume")
/// -> none
#let github-link(github-path) = {
set box(height: 11pt)
align(right + horizon)[
#fa-icon("github", fill: color-darkgray) #link(
"https://github.com/" + github-path,
github-path,
)
]
}
/// Right section for the justified headers
/// - body (content): The body of the right header
#let secondary-right-header(body) = {
set text(
size: 11pt,
weight: "medium",
)
body
}
/// Right section of a tertiaty headers.
/// - body (content): The body of the right header
#let tertiary-right-header(body) = {
set text(
weight: "light",
size: 9pt,
)
body
}
/// Justified header that takes a primary section and a secondary section. The primary section is on the left and the secondary section is on the right.
/// - primary (content): The primary section of the header
/// - secondary (content): The secondary section of the header
#let justified-header(primary, secondary) = {
set block(
above: 0.7em,
below: 0.7em,
)
pad[
#__justify_align[
== #primary
][
#secondary-right-header[#secondary]
]
]
}
/// Justified header that takes a primary section and a secondary section. The primary section is on the left and the secondary section is on the right. This is a smaller header compared to the `justified-header`.
/// - primary (content): The primary section of the header
/// - secondary (content): The secondary section of the header
#let secondary-justified-header(primary, secondary) = {
__justify_align[
=== #primary
][
#tertiary-right-header[#secondary]
]
}
/// --- End of Helpers
/// ---- Resume Template ----
/// Resume template that is inspired by the Awesome CV Latex template by posquit0. This template can loosely be considered a port of the original Latex template.
///
/// The original template: https://github.com/posquit0/Awesome-CV
///
/// - author (content): Structure that takes in all the author's information
/// - date (string): The date the resume was created
/// - accent-color (color): The accent color of the resume
/// - colored-headers (boolean): Whether the headers should be colored or not
/// - language (string): The language of the resume, defaults to "en". See lang.toml for available languages
/// - body (content): The body of the resume
/// -> none
#let resume(
author: (:),
date: datetime.today().display("[month repr:long] [day], [year]"),
accent-color: default-accent-color,
colored-headers: true,
show-footer: true,
language: "en",
font: ("Source Sans Pro", "Source Sans 3"),
header-font: ("Roboto"),
body,
) = {
if type(accent-color) == "string" {
accent-color = rgb(accent-color)
}
let lang_data = toml("lang.toml")
show: body => context {
set document(
author: author.firstname + " " + author.lastname,
title: lflib._linguify("resume", lang: language, from: lang_data).ok,
)
body
}
set text(
font: font,
lang: language,
size: 11pt,
fill: color-darkgray,
fallback: true,
)
set page(
paper: "a4",
margin: (left: 15mm, right: 15mm, top: 10mm, bottom: 10mm),
footer: if show-footer [#__resume_footer(
author,
language,
lang_data,
date,
)] else [],
footer-descent: 0pt,
)
// set paragraph spacing
set par(
spacing: 0.75em,
justify: true,
)
set heading(
numbering: none,
outlined: false,
)
show heading.where(level: 1): it => [
#set text(
size: 16pt,
weight: "regular",
)
#set align(left)
#set block(above: 1em)
#let color = if colored-headers {
accent-color
} else {
color-darkgray
}
#text[#strong[#text(color)[#it.body.text]]]
#box(width: 1fr, line(length: 100%))
]
show heading.where(level: 2): it => {
set text(
color-darkgray,
size: 12pt,
style: "normal",
weight: "bold",
)
it.body
}
show heading.where(level: 3): it => {
set text(
size: 10pt,
weight: "regular",
)
smallcaps[#it.body]
}
let name = {
align(center)[
#pad(bottom: 5pt)[
#block[
#set text(
size: 32pt,
style: "normal",
font: header-font,
)
#if language == "zh" or language == "ja" [
#text(
accent-color,
weight: "thin",
)[#author.firstname]#text(weight: "bold")[#author.lastname]
] else [
#text(accent-color, weight: "thin")[#author.firstname]
#text(weight: "bold")[#author.lastname]
]
]
]
]
}
let positions = {
set text(
accent-color,
size: 9pt,
weight: "regular",
)
align(center)[
#smallcaps[
#author.positions.join(
text[#" "#sym.dot.c#" "],
)
]
]
}
let address = {
set text(
size: 9pt,
weight: "regular",
)
align(center)[
#if ("address" in author) [
#author.address
]
]
}
let contacts = {
set box(height: 9pt)
let separator = box(width: 5pt)
align(center)[
#set text(
size: 9pt,
weight: "regular",
style: "normal",
)
#block[
#align(horizon)[
#if ("birth" in author) [
#birth-icon
#box[#text(author.birth)]
#separator
]
#if ("phone" in author) [
#phone-icon
#box[#text(author.phone)]
#separator
]
#if ("email" in author) [
#email-icon
#box[#link("mailto:" + author.email)[#author.email]]
]
#if ("homepage" in author) [
#separator
#homepage-icon
#box[#link(author.homepage)[#author.homepage]]
]
#if ("github" in author) [
#separator
#github-icon
#box[#link("https://github.com/" + author.github)[#author.github]]
]
#if ("linkedin" in author) [
#separator
#linkedin-icon
#box[
#link("https://www.linkedin.com/in/" + author.linkedin)[#author.firstname #author.lastname]
]
]
#if ("twitter" in author) [
#separator
#twitter-icon
#box[#link("https://twitter.com/" + author.twitter)[\@#author.twitter]]
]
#if ("scholar" in author) [
#let fullname = str(author.firstname + " " + author.lastname)
#separator
#google-scholar-icon
#box[#link("https://scholar.google.com/citations?user=" + author.scholar)[#fullname]]
]
#if ("orcid" in author) [
#separator
#orcid-icon
#box[#link("https://orcid.org/" + author.orcid)[#author.orcid]]
]
#if ("website" in author) [
#separator
#website-icon
#box[#link(author.website)[#author.website]]
]
]
]
]
}
name
positions
address
contacts
body
}
/// The base item for resume entries.
/// This formats the item for the resume entries. Typically your body would be a bullet list of items. Could be your responsibilities at a company or your academic achievements in an educational background section.
/// - body (content): The body of the resume entry
#let resume-item(body) = {
set text(
size: 10pt,
style: "normal",
weight: "light",
fill: color-darknight,
)
set block(
above: 0.75em,
below: 1.25em,
)
set par(leading: 0.65em)
block(above: 0.5em)[
#body
]
}
/// The base item for resume entries. This formats the item for the resume entries. Typically your body would be a bullet list of items. Could be your responsibilities at a company or your academic achievements in an educational background section.
/// - title (string): The title of the resume entry
/// - location (string): The location of the resume entry
/// - date (string): The date of the resume entry, this can be a range (e.g. "Jan 2020 - Dec 2020")
/// - description (content): The body of the resume entry
/// - title-link (string): The link to use for the title (can be none)
/// - accent-color (color): Override the accent color of the resume-entry
/// - location-color (color): Override the default color of the "location" for a resume entry.
#let resume-entry(
title: none,
location: "",
date: "",
description: "",
title-link: none,
accent-color: default-accent-color,
location-color: default-location-color,
) = {
let title-content
if type(title-link) == "string" {
title-content = link(title-link)[#title]
} else {
title-content = title
}
block(above: 1em, below: 0.65em)[
#pad[
#justified-header(title-content, location)
#if description != "" or date != "" [
#secondary-justified-header(description, date)
]
]
]
}
/// Show cumulative GPA.
/// *Example:*
/// #example(`resume.resume-gpa("3.5", "4.0")`)
#let resume-gpa(numerator, denominator) = {
set text(
size: 12pt,
style: "italic",
weight: "light",
)
text[Cumulative GPA: #box[#strong[#numerator] / #denominator]]
}
/// Show a certification in the resume.
/// *Example:*
/// #example(`resume.resume-certification("AWS Certified Solutions Architect - Associate", "Jan 2020")`)
/// - certification (content): The certification
/// - date (content): The date the certification was achieved
#let resume-certification(certification, date) = {
justified-header(certification, date)
}
/// Show a list of skills in the resume under a given category.
/// - category (string): The category of the skills
/// - items (list): The list of skills. This can be a list of strings but you can also emphasize certain skills by using the `strong` function.
#let resume-skill-item(category, items) = {
set block(below: 0.65em)
set pad(top: 2pt)
pad[
#grid(
columns: (20fr, 80fr),
gutter: 10pt,
align(right)[
#set text(hyphenate: false)
== #category
],
align(left)[
#set text(
size: 11pt,
style: "normal",
weight: "light",
)
#items.join(", ")
],
)
]
}
/// ---- End of Resume Template ----
/// ---- Coverletter ----
#let default-closing(lang_data) = {
align(bottom)[
#text(weight: "light", style: "italic")[ #linguify(
"attached",
from: lang_data,
)#sym.colon #linguify("curriculum-vitae", from: lang_data)]
]
}
/// Cover letter template that is inspired by the Awesome CV Latex template by posquit0. This template can loosely be considered a port of the original Latex template.
/// This coverletter template is designed to be used with the resume template.
/// - author (content): Structure that takes in all the author's information. The following fields are required: firstname, lastname, positions. The following fields are used if available: email, phone, github, linkedin, orcid, address, website.
/// - profile-picture (image): The profile picture of the author. This will be cropped to a circle and should be square in nature.
/// - date (datetime): The date the cover letter was created. This will default to the current date.
/// - accent-color (color): The accent color of the cover letter
/// - language (string): The language of the cover letter, defaults to "en". See lang.toml for available languages
/// - font (array): The font families of the cover letter
/// - show-footer (boolean): Whether to show the footer or not
/// - closing (content): The closing of the cover letter. This defaults to "Attached Curriculum Vitae". You can set this to `none` to show the default closing or remove it completely.
/// - body (content): The body of the cover letter
#let coverletter(
author: (:),
profile-picture: image,
date: datetime.today().display("[month repr:long] [day], [year]"),
accent-color: default-accent-color,
language: "en",
font: ("Source Sans Pro", "Source Sans 3"),
show-footer: true,
closing: none,
body,
) = {
if type(accent-color) == "string" {
accent-color = rgb(accent-color)
}
// language data
let lang_data = toml("lang.toml")
if closing == none {
closing = default-closing(lang_data)
}
show: body => context {
set document(
author: author.firstname + " " + author.lastname,
title: lflib._linguify("cover-letter", lang: language, from: lang_data).ok,
)
body
}
set text(
font: font,
lang: language,
size: 11pt,
fill: color-darkgray,
fallback: true,
)
set page(
paper: "a4",
margin: (left: 15mm, right: 15mm, top: 10mm, bottom: 10mm),
footer: if show-footer [#__coverletter_footer(
author,
language,
date,
lang_data,
)] else [],
footer-descent: 0pt,
)
// set paragraph spacing
set par(
spacing: 0.75em,
justify: true,
)
set heading(
numbering: none,
outlined: false,
)
show heading: it => [
#set block(
above: 1em,
below: 1em,
)
#set text(
size: 16pt,
weight: "regular",
)
#align(left)[
#text[#strong[#text(accent-color)[#it.body.text]]]
#box(width: 1fr, line(length: 100%))
]
]
let name = {
align(right)[
#pad(bottom: 5pt)[
#block[
#set text(
size: 32pt,
style: "normal",
font: ("Roboto"),
)
#if language == "zh" or language == "ja" [
#text(
accent-color,
weight: "thin",
)[#author.firstname]#text(weight: "bold")[#author.lastname]
] else [
#text(accent-color, weight: "thin")[#author.firstname]
#text(weight: "bold")[#author.lastname]
]
]
]
]
}
let positions = {
set text(
accent-color,
size: 9pt,
weight: "regular",
)
align(right)[
#smallcaps[
#author.positions.join(
text[#" "#sym.dot.c#" "],
)
]
]
}
let address = {
set text(
size: 9pt,
weight: "bold",
fill: color-gray,
)
align(right)[
#if ("address" in author) [
#author.address
]
]
}
let contacts = {
set box(height: 9pt)
let separator = [ #box(sym.bar.v) ]
let author_list = ()
if ("phone" in author) {
author_list.push[
#phone-icon
#box[#text(author.phone)]
]
}
if ("email" in author) {
author_list.push[
#email-icon
#box[#link("mailto:" + author.email)[#author.email]]
]
}
if ("github" in author) {
author_list.push[
#github-icon
#box[#link("https://github.com/" + author.github)[#author.github]]
]
}
if ("linkedin" in author) {
author_list.push[
#linkedin-icon
#box[
#link("https://www.linkedin.com/in/" + author.linkedin)[#author.firstname #author.lastname]
]
]
}
if ("orcid" in author) {
author_list.push[
#orcid-icon
#box[#link("https://orcid.org/" + author.orcid)[#author.orcid]]
]
}
if ("website" in author) {
author_list.push[
#website-icon
#box[#link(author.website)[#author.website]]
]
}
align(right)[
#set text(
size: 8pt,
weight: "light",
style: "normal",
)
#author_list.join(separator)
]
}
let letter-heading = {
grid(
columns: (1fr, 2fr),
rows: (100pt),
align(left + horizon)[
#block(
clip: true,
stroke: 0pt,
radius: 2cm,
width: 4cm,
height: 4cm,
profile-picture,
)
],
[
#name
#positions
#address
#contacts
],
)
}
let signature = {
align(bottom)[
#pad(bottom: 2em)[
#text(weight: "light")[#linguify(
"sincerely",
from: lang_data,
)#sym.comma] \
#text(weight: "bold")[#author.firstname #author.lastname] \ \
]
]
}
// actual content
letter-heading
body
linebreak()
signature
closing
}
/// Cover letter heading that takes in the information for the hiring company and formats it properly.
/// - entity-info (content): The information of the hiring entity including the company name, the target (who's attention to), street address, and city
/// - date (date): The date the letter was written (defaults to the current date)
#let hiring-entity-info(
entity-info: (:),
date: datetime.today().display("[month repr:long] [day], [year]"),
) = {
set par(leading: 1em)
pad(top: 1.5em, bottom: 1.5em)[
#__justify_align[
#text(weight: "bold", size: 12pt)[#entity-info.target]
][
#text(weight: "light", style: "italic", size: 9pt)[#date]
]
#pad(top: 0.65em, bottom: 0.65em)[
#text(weight: "regular", fill: color-gray, size: 9pt)[
#smallcaps[#entity-info.name] \
#entity-info.street-address \
#entity-info.city \
]
]
]
}
/// Letter heading for a given job position and addressee.
/// - job-position (string): The job position you are applying for
/// - addressee (string): The person you are addressing the letter to
/// - dear (string): optional field for redefining the "dear" variable
#let letter-heading(job-position: "", addressee: "", dear: "") = {
let lang_data = toml("lang.toml")
// TODO: Make this adaptable to content
underline(evade: false, stroke: 0.5pt, offset: 0.3em)[
#text(weight: "bold", size: 12pt)[Job Application for #job-position]
]
pad(top: 1em, bottom: 1em)[
#text(weight: "light", fill: color-gray)[
#if dear == "" [
#linguify("dear", from: lang_data)
] else [
#dear
]
#addressee,
]
]
}
/// Cover letter content paragraph. This is the main content of the cover letter.
/// - content (content): The content of the cover letter
#let coverletter-content(content) = {
pad(top: 1em, bottom: 1em)[
#set par(first-line-indent: 3em)
#set text(weight: "light")
#content
]
}
/// ---- End of Coverletter ----