Skip to content

Commit bd46a82

Browse files
author
Paul T
authored
chore: adjust how contact items are constructed (#145)
1 parent e025cb2 commit bd46a82

File tree

4 files changed

+132
-88
lines changed

4 files changed

+132
-88
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
strategy:
1111
matrix:
1212
# add any other Typst versions that your package should support
13-
typst-version: ["0.12", "0.13"]
13+
typst-version: ["0.12", "0.13", "0.14"]
1414
# the docs don't need to build with all versions supported by the package;
1515
# the latest one is enough
1616
include:
17-
- typst-version: "0.13"
17+
- typst-version: "0.14"
1818
doc: 1
1919
runs-on: ubuntu-22.04
2020
steps:
@@ -40,10 +40,10 @@ jobs:
4040
- name: Install tytanic
4141
uses: taiki-e/cache-cargo-install-action@v2
4242
with:
43-
tool: tytanic@0.2.2
43+
tool: tytanic@0.3.1
4444

4545
- name: Setup typst
46-
uses: typst-community/setup-typst@v3
46+
uses: typst-community/setup-typst@v4
4747
with:
4848
typst-version: ${{ matrix.typst-version }}
4949

lib.typ

Lines changed: 125 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#let website-icon = box(fa-icon("globe", fill: color-darknight))
2828
#let address-icon = box(fa-icon("location-crosshairs", fill: color-darknight))
2929

30+
// const variables
31+
#let contact-item-inset = (left: 4pt)
32+
3033
/// Helpers
3134

3235
// Common helper functions
@@ -131,7 +134,7 @@
131134
set box(height: 11pt)
132135

133136
align(right + horizon)[
134-
#fa-icon("github", fill: color-darkgray) #link(
137+
#fa-icon("github", fill: color-darkgray) #h(2pt) #link(
135138
"https://github.com/" + github-path,
136139
github-path,
137140
)
@@ -186,6 +189,7 @@
186189
///
187190
/// - author (dictionary): Structure that takes in all the author's information
188191
/// - profile-picture (image): The profile picture of the author. This will be cropped to a circle and should be square in nature.
192+
/// - contact-items-separator (content): Separator to use between the "contact" items in the header of the resume. This includes items like your email, website, Github account, phone number and so on. The default is blank spacing.
189193
/// - date (string): The date the resume was created
190194
/// - accent-color (color): The accent color of the resume
191195
/// - colored-headers (boolean): Whether the headers should be colored or not
@@ -199,6 +203,7 @@
199203
#let resume(
200204
author: (:),
201205
profile-picture: image,
206+
contact-items-separator: h(10pt),
202207
date: datetime.today().display("[month repr:long] [day], [year]"),
203208
accent-color: default-accent-color,
204209
colored-headers: true,
@@ -221,11 +226,7 @@
221226

222227
let desc = if description == none {
223228
(
224-
lflib._linguify("resume", lang: language, from: lang_data).ok
225-
+ " "
226-
+ author.firstname
227-
+ " "
228-
+ author.lastname
229+
lflib._linguify("resume", lang: language, from: lang_data).ok + " " + author.firstname + " " + author.lastname
229230
)
230231
} else {
231232
description
@@ -324,125 +325,167 @@
324325
#if ("address" in author) [
325326
#if show-address-icon [
326327
#address-icon
327-
#box[#text(author.address)]
328+
#box(inset: contact-item-inset)[#text(author.address)]
328329
] else [
329330
#text(author.address)
330331
]
331332
]
332333
]
333334
}
334335

336+
// Helper for contact items in the header.
337+
// - item (dictionary): The contact item with the following fields: text (string, required), icon (box, optional), link (string, optional)
338+
// - link-prefix (string): The prefix to use for the link (e.g. "mailto:")
339+
let contact-item(item, link-prefix: "") = {
340+
box[
341+
#set align(bottom)
342+
#if ("icon" in item) {
343+
[#item.icon]
344+
}
345+
// Then modify the selection to use the constant:
346+
#box(inset: contact-item-inset)[
347+
#if ("link" in item) {
348+
link(link-prefix + item.link)[#item.text]
349+
} else {
350+
item.text
351+
}
352+
]
353+
]
354+
}
355+
356+
// Contact section
335357
let contacts = {
336358
set box(height: 9pt)
337359
let items = ()
338-
360+
339361
if "birth" in author {
340-
items.push(box[
341-
#birth-icon
342-
#box[#text(author.birth)]
343-
])
362+
items.push(
363+
contact-item(
364+
(text: author.birth, icon: birth-icon),
365+
),
366+
)
344367
}
345368
if "phone" in author {
346-
items.push(box[
347-
#phone-icon
348-
#box[#link("tel:" + author.phone)[#author.phone]]
349-
])
369+
items.push(
370+
contact-item(
371+
(text: author.phone, icon: phone-icon, link: author.phone),
372+
link-prefix: "tel:",
373+
),
374+
)
350375
}
351376
if "email" in author {
352-
items.push(box[
353-
#email-icon
354-
#box[#link("mailto:" + author.email)[#author.email]]
355-
])
377+
items.push(
378+
contact-item(
379+
(text: author.email, icon: email-icon, link: author.email),
380+
link-prefix: "mailto:",
381+
),
382+
)
356383
}
357384
if "homepage" in author {
358-
items.push(box[
359-
#homepage-icon
360-
#box[#link(author.homepage)[#author.homepage]]
361-
])
385+
items.push(
386+
contact-item(
387+
(text: author.homepage, icon: homepage-icon, link: author.homepage),
388+
),
389+
)
362390
}
363391
if "github" in author {
364-
items.push(box[
365-
#github-icon
366-
#box[#link("https://github.com/" + author.github)[#author.github]]
367-
])
392+
items.push(
393+
contact-item(
394+
(text: author.github, icon: github-icon, link: author.github),
395+
link-prefix: "https://github.com/",
396+
),
397+
)
368398
}
369399
if "gitlab" in author {
370-
items.push(box[
371-
#gitlab-icon
372-
#box[#link("https://gitlab.com/" + author.gitlab)[#author.gitlab]]
373-
])
400+
items.push(
401+
contact-item(
402+
(text: author.gitlab, icon: gitlab-icon, link: author.gitlab),
403+
link-prefix: "https://gitlab.com/",
404+
),
405+
)
374406
}
375407
if "bitbucket" in author {
376-
items.push(box[
377-
#bitbucket-icon
378-
#box[#link(
379-
"https://bitbucket.org/" + author.bitbucket,
380-
)[#author.bitbucket]]
381-
])
408+
items.push(
409+
contact-item(
410+
(text: author.bitbucket, icon: bitbucket-icon, link: author.bitbucket),
411+
link-prefix: "https://bitbucket.org/",
412+
),
413+
)
382414
}
383415
if "linkedin" in author {
384-
items.push(box[
385-
#linkedin-icon
386-
#box[
387-
#link(
388-
"https://www.linkedin.com/in/" + author.linkedin,
389-
)[#author.firstname #author.lastname]
390-
]
391-
])
416+
items.push(
417+
contact-item(
418+
(
419+
text: author.firstname + " " + author.lastname,
420+
icon: linkedin-icon,
421+
link: author.linkedin,
422+
),
423+
link-prefix: "https://www.linkedin.com/in/",
424+
),
425+
)
392426
}
393427
if "twitter" in author {
394-
items.push(box[
395-
#twitter-icon
396-
#box[#link(
397-
"https://twitter.com/" + author.twitter,
398-
)[\@#author.twitter]]
399-
])
428+
items.push(
429+
contact-item(
430+
(text: "@" + author.twitter, icon: twitter-icon, link: author.twitter),
431+
link-prefix: "https://twitter.com/",
432+
),
433+
)
400434
}
401435
if "scholar" in author {
402436
let fullname = str(author.firstname + " " + author.lastname)
403-
items.push(box[
404-
#google-scholar-icon
405-
#box[#link(
406-
"https://scholar.google.com/citations?user=" + author.scholar,
407-
)[#fullname]]
408-
])
437+
items.push(
438+
contact-item(
439+
(text: fullname, icon: google-scholar-icon, link: author.scholar),
440+
link-prefix: "https://scholar.google.com/citations?user=",
441+
),
442+
)
409443
}
410444
if "orcid" in author {
411-
items.push(box[
412-
#orcid-icon
413-
#box[#link("https://orcid.org/" + author.orcid)[#author.orcid]]
414-
])
445+
items.push(
446+
contact-item(
447+
(text: author.orcid, icon: orcid-icon, link: author.orcid),
448+
link-prefix: "https://orcid.org/",
449+
),
450+
)
415451
}
416452
if "website" in author {
417-
items.push(box[
418-
#website-icon
419-
#box[#link(author.website)[#author.website]]
420-
])
453+
items.push(
454+
contact-item(
455+
(text: author.website, icon: website-icon, link: author.website),
456+
),
457+
)
421458
}
422459
if "custom" in author and type(author.custom) == array {
423460
for item in author.custom {
424461
if "text" in item {
425-
items.push(box[
426-
#if ("icon" in item) {
427-
box(fa-icon(item.icon, fill: color-darknight))
428-
}
429-
#box[
430-
#if ("link" in item) {
431-
link(item.link)[#item.text]
432-
} else {
433-
item.text
434-
}
435-
]
436-
])
462+
items.push(
463+
contact-item(
464+
(
465+
text: item.text,
466+
icon: if ("icon" in item) {
467+
box(fa-icon(item.icon, fill: color-darknight))
468+
} else {
469+
none
470+
},
471+
link: if ("link" in item) {
472+
item.link
473+
} else {
474+
none
475+
},
476+
),
477+
link-prefix: "",
478+
),
479+
)
437480
}
438481
}
439482
}
440483

441-
align(center+horizon)[
484+
align(center + horizon)[
442485
#set text(size: 9pt, weight: "regular", style: "normal")
443486
#block[
444-
#align(bottom)[
445-
#items.join(h(10pt))
487+
#align(center + horizon)[
488+
#items.join(contact-items-separator)
446489
]
447490
]
448491
]
@@ -672,9 +715,7 @@
672715
show: body => context {
673716
set document(
674717
author: author.firstname + " " + author.lastname,
675-
title: lflib
676-
._linguify("cover-letter", lang: language, from: lang_data)
677-
.ok,
718+
title: lflib._linguify("cover-letter", lang: language, from: lang_data).ok,
678719
description: desc,
679720
keywords: keywords,
680721
)

template/resume.typ

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
homepage: "https://example.com",
99
phone: "(+1) 111-111-1111",
1010
github: "DeveloperPaul123",
11+
gitlab: "DeveloperPaul123",
12+
bitbucket: "DeveloperPaul123",
1113
twitter: "typstapp",
1214
scholar: "",
1315
orcid: "0000-0000-0000-000X",
@@ -36,6 +38,7 @@
3638
show-footer: false,
3739
show-address-icon: true,
3840
paper-size: "us-letter",
41+
contact-items-separator: box[#h(2pt)#text("|")#h(2pt)],
3942
)
4043

4144
= Experience

tests/utilities/ref/1.png

-5 Bytes
Loading

0 commit comments

Comments
 (0)