summaryrefslogtreecommitdiff
path: root/build.py
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2026-06-15 20:25:47 +0200
committerPaweł Redman <pawel.redman@gmail.com>2026-06-15 20:25:47 +0200
commit6ecf59b7a764a1ec03289473a9735c10a9896211 (patch)
tree934a7f8b27d04bee10f01559f5a39f19684b57f4 /build.py
parent9f72120b9ff063ab0d41f850a7bb6ee394a623b7 (diff)
WIP
Diffstat (limited to 'build.py')
-rw-r--r--build.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/build.py b/build.py
index 799eceb..15fe9b8 100644
--- a/build.py
+++ b/build.py
@@ -53,6 +53,7 @@ class Builder:
)
)
+ # FIXME: can we use one field for date?
if 'date_year' in metadata:
date = datetime(
year=metadata['date_year'],
@@ -72,13 +73,17 @@ class Builder:
return [self._compile_typst_page(path) for path in self.content_dir.rglob('*.typ')]
def _compile_index_page(self, pages: list[CompiledPage]) -> None:
- # pages.sort(key=lambda page: page.date)
- # template = jinja2.Template((self.site_dir / 'index.html').read_text())
- # (self.public_dir / 'index.html').write_text(template.render(pages=pages))
-
payload_path = self.temp_dir / 'payload.json'
payload_path.parent.mkdir(parents=True, exist_ok=True)
+ # Maybe sorting/filtering should be done in Typst?
+ pages = [
+ page
+ for page in pages
+ if page.date is not None
+ ]
+ pages.sort(key=lambda page: page.date, reverse=True)
+
with payload_path.open('w') as file:
payload = {
'pages': [
@@ -90,7 +95,6 @@ class Builder:
'day': page.date.day if page.date else None,
}
for page in pages
- if page.date is not None
],
}
json.dump(payload, file)