From db4c99af282f3aea9e207c30db983e53203513eb Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Mon, 7 Jul 2025 09:30:34 -0500 Subject: fix: ignore draft posts when publishing --- build.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'build.py') diff --git a/build.py b/build.py index 59118fb..0b08bd8 100644 --- a/build.py +++ b/build.py @@ -115,6 +115,7 @@ def get_recent_posts_html(content_dir="./content/blog", num_posts=3): "date": re.compile(r"^#\+date:\s*<(\d{4}-\d{2}-\d{2})"), "slug": re.compile(r"^#\+slug:\s*(.+)$", re.IGNORECASE), "filetags": re.compile(r"^#\+filetags:\s*(.+)$", re.IGNORECASE), + "draft": re.compile(r"^#\+draft:\s*(.+)$", re.IGNORECASE), } for org_path in Path(content_dir).glob("*.org"): @@ -122,6 +123,7 @@ def get_recent_posts_html(content_dir="./content/blog", num_posts=3): date_str = None slug = None tags = [] + is_draft = False with org_path.open("r", encoding="utf-8") as f: for line in f: @@ -153,17 +155,28 @@ def get_recent_posts_html(content_dir="./content/blog", num_posts=3): tags = [t for t in raw.split(":") if t] continue + m = header_patterns["draft"].match(line) + if m: + draft_value = m.group(1).strip().lower() + if draft_value != "nil": + is_draft = True + break + continue + # Stop scanning once we have all required fields if title and date_str and slug and tags: break + if is_draft: + continue + if title and date_str and slug: try: date_obj = datetime.strptime(date_str, "%Y-%m-%d") except ValueError: # Skip files with invalid date format continue - + posts.append( { "title": title, -- cgit v1.2.3-70-g09d2 From 444ec6a63a1ffe94c6ffb5e6aa7fc8cdcc81dbb9 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 7 Jul 2025 14:31:03 +0000 Subject: Commit from GitHub Actions (Ruff) --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'build.py') diff --git a/build.py b/build.py index 0b08bd8..ee947f3 100644 --- a/build.py +++ b/build.py @@ -176,7 +176,7 @@ def get_recent_posts_html(content_dir="./content/blog", num_posts=3): except ValueError: # Skip files with invalid date format continue - + posts.append( { "title": title, -- cgit v1.2.3-70-g09d2