summaryrefslogtreecommitdiff
path: root/build.py
diff options
context:
space:
mode:
Diffstat (limited to 'build.py')
-rw-r--r--build.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/build.py b/build.py
index 2dd8504..e253d4c 100644
--- a/build.py
+++ b/build.py
@@ -10,7 +10,7 @@ from pathlib import Path
import jinja2
from loguru import logger
-from typst import Compiler
+from typst import Compiler, TypstError
from watchfiles import watch
@@ -36,7 +36,13 @@ class Builder:
output_path = self.public_dir / relative_path.with_suffix('.html')
output_path.parent.mkdir(parents=True, exist_ok=True)
- self.compiler.compile(input=path, output=output_path)
+ self.compiler.compile(
+ input=path,
+ output=output_path,
+ sys_inputs={
+ 'path': str(relative_path.with_suffix('')),
+ },
+ )
metadata = json.loads(
self.compiler.query(
@@ -98,7 +104,10 @@ def main() -> None:
for changes in watch(site_dir):
print(changes)
- builder.build()
+ try:
+ builder.build()
+ except TypstError as e:
+ logger.exception(e)
if __name__ == '__main__':