diff --git a/Makefile b/Makefile index 511c7a9..353791f 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ watch: make build echo "Started watcher..." while true; do \ - inotifywait -qr -e modify -e create -e delete -e move --include 'src/.*$$' --include 'scripts/.*$$' .; \ + inotifywait -qr -e modify -e create -e delete -e move --include '(src|scripts)/.*$$' .; \ make build; \ done diff --git a/scripts/build.py b/scripts/build.py index ad3ce6f..f4ed801 100755 --- a/scripts/build.py +++ b/scripts/build.py @@ -2,6 +2,7 @@ from __future__ import annotations +import functools import json import os import shutil @@ -27,18 +28,32 @@ @dataclasses.dataclass class PostMeta: + slug: str title: str timestamp: datetime public: bool @classmethod - def parse(cls, d: dict[str, Any]) -> PostMeta: + def parse(cls, slug: str, d: dict[str, Any]) -> PostMeta: return cls( + slug=slug, title=d["title"], timestamp=datetime.fromisoformat(d["timestamp"]), public=d["public"], ) + @functools.cached_property + def lastupdated(self) -> datetime | None: + p = f"src/posts/tex/{self.slug}.tex" + r = subprocess.run(["git", "log", "-1", "--format=%cI", p], capture_output=True, text=True) + text = r.stdout.strip() + if not text: + return None + lastupdated = datetime.fromisoformat(text).astimezone(pytz.utc) + if lastupdated.date() == self.timestamp.date(): + return None + return lastupdated + PostIndex = dict[str, PostMeta] @@ -52,13 +67,6 @@ def site_updated_at() -> datetime: return datetime.fromisoformat(text).astimezone(pytz.utc) -def article_updated_at(slug: str) -> datetime: - p = f"src/posts/tex/{slug}.tex" - r = subprocess.run(["git", "log", "-1", "--format=%cI", p], capture_output=True, text=True) - text = r.stdout.strip() - return datetime.fromisoformat(text).astimezone(pytz.utc) - - # BUILD STEPS @@ -84,13 +92,13 @@ def compile_index(posts: PostIndex): tpl = je.from_string(fp.read()) # Write the main index.html - publicposts = {k: v for k, v in posts.items() if v.public} + publicposts = {k: v for k, v in reversed(posts.items()) if v.public} index = tpl.render(posts=publicposts) with Path("dist/index.html").open("w") as fp: fp.write(index) # Write a staging index.html - staging = tpl.render(posts=posts) + staging = tpl.render(posts=dict(reversed(posts.items()))) with Path("dist/staging.html").open("w") as fp: fp.write(staging) @@ -153,7 +161,7 @@ def compile_feed(posts: PostIndex): SubElement(post, "link", href=f"https://sunsetglow.net/posts/{slug}.html", type="text/html") SubElement(post, "title").text = meta.title SubElement(post, "published").text = meta.timestamp.isoformat() - SubElement(post, "updated").text = article_updated_at(slug).isoformat() + SubElement(post, "updated").text = (meta.lastupdated or meta.timestamp).isoformat() author = SubElement(post, "author") SubElement(author, "name").text = "blissful" @@ -169,7 +177,7 @@ def main(): os.chdir(PROJECT_DIR) with Path("src/posts/index.json").open("r") as fp: - posts = {k: PostMeta.parse(v) for k, v in json.load(fp).items()} + posts = {k: PostMeta.parse(k, v) for k, v in json.load(fp).items()} empty_dist() shutil.copytree("src/assets", "dist/assets") diff --git a/src/assets/css/global.css b/src/assets/css/global.css index e071642..ebd18a9 100644 --- a/src/assets/css/global.css +++ b/src/assets/css/global.css @@ -236,6 +236,9 @@ code { /* Flex. */ .flex { display: flex } .flex-col { flex-direction: column } +.justify-center { justify-content: center } +.justify-between { justify-content: space-between } +.align-center { align-items: center } /* Gap. */ .gap-1 { gap: .25rem } diff --git a/src/assets/css/post.css b/src/assets/css/post.css index 3711424..c68a532 100644 --- a/src/assets/css/post.css +++ b/src/assets/css/post.css @@ -58,7 +58,9 @@ padding-bottom: .75rem; } -.pandoc p { +.pandoc p, +.pandoc pre, +.pandoc blockquote { padding-bottom: .5rem; } @@ -66,8 +68,14 @@ font-size: var(--font-size-xs); } +.pandoc pre, +.pandoc pre code { + padding-bottom: .5rem; + font-size: var(--font-size-xs); +} + .pandoc blockquote { - margin: .5rem 1.5rem; + margin: 0 1.5rem; line-height: 1.25; font-size: var(--font-size-xs); color: var(--color-fg-secondary); diff --git a/src/index.jinja b/src/index.jinja index 5e778e6..0c7c775 100644 --- a/src/index.jinja +++ b/src/index.jinja @@ -7,7 +7,7 @@