From 5234c4c2f2435c92c7ff8708a89cb791d81f4c47 Mon Sep 17 00:00:00 2001 From: mintyfrankie <77310871+mintyfrankie@users.noreply.github.com> Date: Fri, 12 Jul 2024 15:06:24 +0200 Subject: [PATCH] refactor(cv): include declaratives in show function --- brilliant-CV/template.typ | 31 +++++++++++++++++++++---------- brilliant-CV/utils/lang.typ | 4 ++-- cv.typ | 21 +++++++++++---------- metadata.toml | 11 ++++++++--- 4 files changed, 42 insertions(+), 25 deletions(-) diff --git a/brilliant-CV/template.typ b/brilliant-CV/template.typ index 7850c52..4e2940a 100644 --- a/brilliant-CV/template.typ +++ b/brilliant-CV/template.typ @@ -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") @@ -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, @@ -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, ) @@ -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 { @@ -336,7 +340,7 @@ { entryA1Style( ifSocietyFirst( - metadata.layout.display_entry_society_first, + metadata.layout.entry.display_entry_society_first, society, title, ), @@ -345,7 +349,7 @@ { entryA2Style( ifSocietyFirst( - metadata.layout.display_entry_society_first, + metadata.layout.entry.display_entry_society_first, location, date, ), @@ -355,7 +359,7 @@ { entryB1Style( ifSocietyFirst( - metadata.layout.display_entry_society_first, + metadata.layout.entry.display_entry_society_first, title, society, ), @@ -364,7 +368,7 @@ { entryB2Style( ifSocietyFirst( - metadata.layout.display_entry_society_first, + metadata.layout.entry.display_entry_society_first, date, location, ), @@ -453,7 +457,7 @@ bibliography(bibPath, title: none, style: refStyle, full: refFull) } -#let cvFooter() = { +#let cvFooter(metadata) = { place( bottom, table( @@ -522,6 +526,7 @@ /* Layout */ #let cv( metadata_path: "../metadata.toml", + include_modules: list(), doc, ) = { // Load metadata @@ -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) } diff --git a/brilliant-CV/utils/lang.typ b/brilliant-CV/utils/lang.typ index d0e4b59..a0fdc64 100644 --- a/brilliant-CV/utils/lang.typ +++ b/brilliant-CV/utils/lang.typ @@ -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" } } diff --git a/cv.typ b/cv.typ index 621f1aa..0211f76 100644 --- a/cv.typ +++ b/cv.typ @@ -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", + ), +) diff --git a/metadata.toml b/metadata.toml index 9e52bc7..8716e84 100644 --- a/metadata.toml +++ b/metadata.toml @@ -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