Support specifying content path in arguments

This commit is contained in:
Artemis Tosini 2023-12-01 02:40:44 +00:00
parent 358e68c8db
commit 72fbcb42d6
Signed by: artemist
GPG key ID: EE5227935FE3FF18
2 changed files with 19 additions and 2 deletions

View file

@ -116,7 +116,7 @@
let content_fn = if args.no_content {
_ => []
} else {
import "content/content.typ"
import "cache/content/content.typ"
content.content
}

View file

@ -5,6 +5,7 @@ import csv
import hashlib
import json
import os
import pathlib
import string
import typing
import urllib.parse
@ -160,6 +161,14 @@ parser.add_argument(
help="CSV file containing addresses",
)
parser.add_argument(
"-i",
"--content-path",
default="content",
type=str,
help="Directory containing content files",
)
parser.add_argument(
"-n",
"--no-content",
@ -216,6 +225,14 @@ for row in rows:
}
]
# Typst can't access files outside the project root, except through a symlink
# Create one in cache to use here
if not os.path.exists("cache"):
os.mkdir("cache")
p = pathlib.Path("cache/content")
p.unlink(missing_ok=True)
p.symlink_to(args.content_path)
cards = cards * args.count
serial = imb.get_first_serial()
@ -246,7 +263,7 @@ os.execlp(
"typst",
"watch" if args.watch else "compile",
"--font-path",
"content",
args.content_path,
"--font-path",
os.getenv("TYPST_FONT_PATHS"),
args.template,