Refactor typst cv generation to make use of generalized entries

This commit is contained in:
Marty Oehme 2024-09-15 17:56:18 +02:00
parent d518eb9087
commit e53d5ca386
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

142
cv.typ
View file

@ -32,31 +32,6 @@
]
}
// Feel free to change the margin below to best fit your own CV
#set page(
paper: "a4",
margin: (x: 0.9cm, y: 1.3cm),
footer: [
#set text(
fill: luma(200),
size: 8pt,
)
#_columns_3[
#smallcaps[#datetime.today().display("[month repr:long] [day], [year]")]
][
#smallcaps[
Marty Oehme
// #sym.dot.c
// CV
]
][
#counter(page).display()
]
],
)
#set par(justify: true)
#let header(about, columns: (1.5fr, 1fr, 1fr)) = {
[= #about.fullname];
let contact_fields = (for c in about.contact {
@ -73,41 +48,63 @@
);
}
#let horizon_line() = {v(-3pt); line(length: 100%); v(-5pt)}
#let subdued(body) = {
block(inset: 5%, width: 85%, text(fill:luma(150), body))
}
#let section_header(title) = {[== #title]; horizon_line()};
#let section(title: "Section", body) = {
section_header(title);
body
};
#let work_item(item: ()) = {
if "client" in item {
[*#item.title.at(lang)*, _#item.client.at(lang)_ #h(1fr)];
} else {
[*#item.title.at(lang)* #h(1fr)];
};
[ _#item.date.at(lang)_ \ ];
#let entry(item: ()) = {
if "title" in item {
[*#item.title.at(lang)*]
}
if "place" in item {
if "title" in item {
[, ]
}
[_#item.place.at(lang)_]
}
[#h(1fr)]
if "date" in item {
[ _#item.date.at(lang)_ \ ]
}
if "bullets" in item {
for bullet in item.bullets {
[- #bullet.at(lang)]
}
}
if "publication" in item {
block(inset: 5%, width: 85%, text(fill:luma(150))[#item.publication.at(lang) \ ])
subdued[#item.publication.at(lang) \ ]
};
if "abstract" in item {
subdued[#item.abstract.at(lang) \ ]
}
}
#let education_item(item: ()) = {
assert("place" in item and "program" in item and "date" in item, message: "Education items require place, program and date.");
[*#item.place.at(lang)*, #item.program.at(lang) #h(1fr)];
#let horizon_line() = {v(-3pt); line(length: 100%); v(-5pt)}
#let section_header(title) = {[== #title]; horizon_line()};
#let section(title: "Section", entries: (), body) = {
section_header(title);
if body == none or body == [] {
for e in entries {
entry(item:e)
}
} else {
body
}
};
// Slightly re-styled entry with PLACE first and TITLE second
#let education_entry(item: ()) = {
assert("place" in item and "title" in item and "date" in item, message: "Education items require place, program and date.");
[*#item.place.at(lang)*, #item.title.at(lang) #h(1fr)];
[ _#item.date.at(lang)_ \ ];
}
#let thesis_item(item: ()) = {
assert("type" in item and "title" in item, message: "Thesis items require type and title.");
[*#item.type.at(lang)* #item.title.at(lang) #h(1fr)];
// Restyled entry with PLACE not emphasized like usual, and no date but an abstract
#let thesis_entry(item: ()) = {
assert("title" in item and "place" in item, message: "Thesis items require type and title.");
[*#item.title.at(lang)* #item.place.at(lang) #h(1fr)];
[#par(item.abstract.at(lang))]
}
@ -119,6 +116,7 @@
}
}
// Old-style presentation of skills and qualifications, to be overhauled
#let skill_item(item: ()) = {
[*#item.at(lang)*: \ ]
for skill in item.content {
@ -133,9 +131,35 @@
}
}
#let resume(contents) = {
// Feel free to change the margin below to best fit your own CV
set page(
paper: "a4",
margin: (x: 0.9cm, y: 1.3cm),
footer: [
#set text(
fill: luma(200),
size: 8pt,
)
#_columns_3[
#smallcaps[#datetime.today().display("[month repr:long] [day], [year]")]
][
#smallcaps[
// FIXME: Source from about.fullname variable
Marty Oehme
// #sym.dot.c
// CV
]
][
#counter(page).display()
]
],
)
set par(justify: true)
header(contents.about)
if "summary" in contents {
section(title:"", {
contents.summary.at(lang)
@ -144,23 +168,17 @@
if "experience" in contents {
let title = sel_word_lang(en:"Professional Experience", de:"Berufserfahrung")
section(title: title, {
for entry in contents.experience {
work_item(item:entry)
}
})
}
section(title: title, entries:contents.experience)[]
}
if "education" in contents {
let title = sel_word_lang(en:"Education", de:"Ausbildung")
section(title: "Education", {
for entry in contents.thesis {
thesis_item(item:entry)
}
for entry in contents.education {
education_item(item:entry)
}
})
section(title: title, entries:contents.thesis + contents.education)[]
}
if "volunteering" in contents {
let title = sel_word_lang(en:"Volunteer Work", de:"Ehrenamt")
section(title: title, entries:contents.volunteering)[]
}
if "skills" in contents {