From d27b64bd402826de46dd6bfcefe7711eae55b4e1 Mon Sep 17 00:00:00 2001 From: Bauke Date: Tue, 16 Jan 2024 18:17:53 +0100 Subject: [PATCH] Replace compilation with a temporary script. --- .gitignore | 1 + Makefile.toml | 9 ++------- compile-cv.zsh | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) create mode 100755 compile-cv.zsh diff --git a/.gitignore b/.gitignore index 9bdb3b1..5a8f3c7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .vscode/ build/ data/ +cv.typ diff --git a/Makefile.toml b/Makefile.toml index 3c885fa..67cb28d 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -23,12 +23,7 @@ args = ["trash", "build"] [tasks.compile] clear = true dependencies = ["ensure-build-dir"] -command = "typst" -args = [ - "compile", - "cv-${CV_LANG}.typ", - "build/CV-Bauke-${CV_LANG}.pdf" -] +script = "./compile-cv.zsh" # Ensure that the build directory exists. [tasks.ensure-build-dir] @@ -41,4 +36,4 @@ args = ["-p", "build"] [tasks.watch] clear = true command = "watchexec" -args = ["-e", "toml,typ", "--no-vcs-ignore", "makers build"] +args = ["-e", "toml,typ", "-i", "cv.typ", "--no-vcs-ignore", "makers build"] diff --git a/compile-cv.zsh b/compile-cv.zsh new file mode 100755 index 0000000..27ca238 --- /dev/null +++ b/compile-cv.zsh @@ -0,0 +1,20 @@ +#!/usr/bin/env zsh + +# There's currently no way in Typst to provide values from the CLI in some way +# so until the next version lands and https://github.com/typst/typst/pull/2894 +# becomes available, a script that renders a template has to be it for now. + +# Define options based on environment variables or use default values. +include_links=${CV_INCLUDE_LINKS:-"true"} +language=${CV_LANG:-"en"} + +typst_template="#import \"main.typ\": cv + +#cv( + include_links: $include_links, + language: \"$language\", +)" + +echo $typst_template > cv.typ + +typst compile cv.typ "build/CV-Bauke-$CV_LANG.pdf"