49 lines
1.2 KiB
Plaintext
49 lines
1.2 KiB
Plaintext
#import "modules/model.typ": report-model
|
|
|
|
#let report-file = sys.inputs.at("report", default: none)
|
|
|
|
#if report-file == none {
|
|
panic(
|
|
"Missing report input.\n" +
|
|
"Usage: typst compile --input report=reports/foo.yaml report.typ foo.pdf"
|
|
)
|
|
}
|
|
|
|
#let report = yaml(report-file)
|
|
#let metadata = report.at("metadata", default: (:))
|
|
|
|
#if "Author" not in metadata or str.trim(str(metadata.at("Author", default: ""))) == "" {
|
|
panic(
|
|
"Missing required report field: metadata.Author.\n" +
|
|
"Add this to the report YAML:\n\n" +
|
|
"metadata:\n Author: \"Your name\""
|
|
)
|
|
}
|
|
|
|
#if "Date" not in metadata or str.trim(str(metadata.at("Date", default: ""))) == "" {
|
|
panic(
|
|
"Missing required report field: metadata.Date.\n" +
|
|
"Add this to the report YAML:\n\n" +
|
|
"metadata:\n Date: \"YYYY-MM-DD\""
|
|
)
|
|
}
|
|
|
|
#let themes = yaml("config/themes.yaml")
|
|
#let theme-name = lower(str(report.at("theme", default: "default")))
|
|
|
|
#if theme-name not in themes {
|
|
panic(
|
|
"Unknown report theme: \"" + theme-name + "\".\n" +
|
|
"Set theme to one of: " + themes.keys().join(", ") + ".\n" +
|
|
"Example: theme: default"
|
|
)
|
|
}
|
|
|
|
#let theme = themes.at(theme-name)
|
|
|
|
#show: report-model.with(
|
|
report: report,
|
|
theme: theme,
|
|
logo: "/assets/beffroi.png",
|
|
)
|