diff options
| author | Christian Cleberg <[email protected]> | 2025-07-07 09:30:34 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2025-07-07 09:30:34 -0500 |
| commit | 99575d28c574803e78084ac5ce0eb499e0e8fdce (patch) | |
| tree | 9927d49ac907f972a9fbafb5bb33cb103b1c46ce /build.py | |
| parent | 037a40e4a59d9a516ae9e4a1c8e547c37850ad72 (diff) | |
| download | cleberg.net-99575d28c574803e78084ac5ce0eb499e0e8fdce.tar.gz cleberg.net-99575d28c574803e78084ac5ce0eb499e0e8fdce.tar.bz2 cleberg.net-99575d28c574803e78084ac5ce0eb499e0e8fdce.zip | |
fix: ignore draft posts when publishing
Diffstat (limited to 'build.py')
| -rw-r--r-- | build.py | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -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, |
