Skip to content

Commit

Permalink
refactor(cv): include declaratives in show function
Browse files Browse the repository at this point in the history
  • Loading branch information
mintyfrankie committed Jul 12, 2024
1 parent f345789 commit 5234c4c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 25 deletions.
31 changes: 21 additions & 10 deletions brilliant-CV/template.typ
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Packages */
#import "@preview/fontawesome:0.2.1": *
#import "./utils/injection.typ": inject
#import "./utils/lang.typ": languageSwitch
#import "./utils/lang.typ": languageSwitch, autoImport

/* Import metadata */
#let metadata = toml("../metadata.toml")
Expand Down Expand Up @@ -69,7 +69,11 @@
}

/* Functions */
#let cvHeader(align: left, hasPhoto: true) = {
#let cvHeader(metadata) = {
// Parameters
let hasPhoto = metadata.layout.header.display_profile_photo
let align = eval(metadata.layout.header.header_align)

// Injection
inject(
if_inject_ai_prompt: metadata.inject.inject_ai_prompt,
Expand Down Expand Up @@ -172,9 +176,9 @@
)

let makeHeaderPhotoSection() = {
if metadata.layout.display_profile_photo {
if metadata.layout.header.display_profile_photo {
box(
image(metadata.layout.profile_photo_path, height: 3.6cm),
image(metadata.layout.header.profile_photo_path, height: 3.6cm),
radius: 50%,
clip: true,
)
Expand Down Expand Up @@ -296,7 +300,7 @@
}
}
let ifLogo(path, ifTrue, ifFalse) = {
return if metadata.layout.display_logo {
return if metadata.layout.entry.display_logo {
if path == "" {
ifFalse
} else {
Expand Down Expand Up @@ -336,7 +340,7 @@
{
entryA1Style(
ifSocietyFirst(
metadata.layout.display_entry_society_first,
metadata.layout.entry.display_entry_society_first,
society,
title,
),
Expand All @@ -345,7 +349,7 @@
{
entryA2Style(
ifSocietyFirst(
metadata.layout.display_entry_society_first,
metadata.layout.entry.display_entry_society_first,
location,
date,
),
Expand All @@ -355,7 +359,7 @@
{
entryB1Style(
ifSocietyFirst(
metadata.layout.display_entry_society_first,
metadata.layout.entry.display_entry_society_first,
title,
society,
),
Expand All @@ -364,7 +368,7 @@
{
entryB2Style(
ifSocietyFirst(
metadata.layout.display_entry_society_first,
metadata.layout.entry.display_entry_society_first,
date,
location,
),
Expand Down Expand Up @@ -453,7 +457,7 @@
bibliography(bibPath, title: none, style: refStyle, full: refFull)
}

#let cvFooter() = {
#let cvFooter(metadata) = {
place(
bottom,
table(
Expand Down Expand Up @@ -522,6 +526,7 @@
/* Layout */
#let cv(
metadata_path: "../metadata.toml",
include_modules: list(),
doc,
) = {
// Load metadata
Expand All @@ -534,5 +539,11 @@
paper: "a4",
margin: (left: 1.4cm, right: 1.4cm, top: .8cm, bottom: .4cm),
)

cvHeader(metadata)
for i in include_modules {
autoImport(i, metadata.language)
}
doc
cvFooter(metadata)
}
4 changes: 2 additions & 2 deletions brilliant-CV/utils/lang.typ
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ A module containing the language logic for the CV template.
/* Import metadata */
#let metadata = toml("../../metadata.toml")

#let autoImport(file) = {
#let autoImport(file, lang) = {
include {
"../../modules_" + metadata.language + "/" + file + ".typ"
"../../modules_" + lang + "/" + file + ".typ"
}
}

Expand Down
21 changes: 11 additions & 10 deletions cv.typ
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#import "brilliant-CV/template.typ": *
#import "brilliant-CV/utils/lang.typ": autoImport
#show: cv.with(metadata_path: "../metadata.toml")

#cvHeader(hasPhoto: true, align: left)
#autoImport("education")
#autoImport("professional")
#autoImport("projects")
#autoImport("certificates")
#autoImport("publications")
#autoImport("skills")
#cvFooter()
#show: cv.with(
metadata_path: "../metadata.toml",
include_modules: (
"education",
"professional",
"projects",
"certificates",
"publications",
"skills",
),
)
11 changes: 8 additions & 3 deletions metadata.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ language = "en"

[layout]
awesome_color = "skyblue"
before_section_skip = "1pt"
before_entry_skip = "1pt"
before_entry_description_skip = "1pt"

[layout.header]
header_align = "left"
display_profile_photo = true
profile_photo_path = "../src/avatar.png"

[layout.entry]
display_entry_society_first = true
display_logo = true
before_section_skip = "1pt"
before_entry_skip = "1pt"
before_entry_description_skip = "1pt"

[inject]
inject_ai_prompt = false
Expand Down

0 comments on commit 5234c4c

Please sign in to comment.