summaryrefslogtreecommitdiff
path: root/build.py
diff options
context:
space:
mode:
Diffstat (limited to 'build.py')
-rw-r--r--build.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/build.py b/build.py
index 38d7eb4..799eceb 100644
--- a/build.py
+++ b/build.py
@@ -17,7 +17,7 @@ from watchfiles import DefaultFilter, watch
class CompiledPage:
url: str
title: str
- date: datetime
+ date: datetime | None
class Builder:
@@ -53,14 +53,19 @@ class Builder:
)
)
- return CompiledPage(
- url=str(relative_path.with_suffix('.html')),
- title=metadata['title'],
- date=datetime(
+ if 'date_year' in metadata:
+ date = datetime(
year=metadata['date_year'],
month=metadata['date_month'],
day=metadata['date_day'],
- ),
+ )
+ else:
+ date = None
+
+ return CompiledPage(
+ url=str(relative_path.with_suffix('.html')),
+ title=metadata['title'],
+ date=date,
)
def _compile_typst_pages(self) -> list[CompiledPage]:
@@ -74,19 +79,18 @@ class Builder:
payload_path = self.temp_dir / 'payload.json'
payload_path.parent.mkdir(parents=True, exist_ok=True)
- pages.sort(key=lambda page: page.date, reverse=True)
-
with payload_path.open('w') as file:
payload = {
'pages': [
{
'url': page.url,
'title': page.title,
- 'year': page.date.year,
- 'month': page.date.month,
- 'day': page.date.day,
+ 'year': page.date.year if page.date else None,
+ 'month': page.date.month if page.date else None,
+ 'day': page.date.day if page.date else None,
}
for page in pages
+ if page.date is not None
],
}
json.dump(payload, file)