From 066b7a098b57f012a458aae2087429d4421af5c9 Mon Sep 17 00:00:00 2001 From: Kumi Date: Wed, 27 Nov 2024 16:18:16 +0100 Subject: [PATCH] feat: Enhances future post handling and default metadata Improves handling of future posts by checking date type before parsing. Adds default metadata for blog posts, including license and author details, ensuring consistency and compliance with CC BY-SA 4.0. --- main.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 6460186..5c5edf2 100644 --- a/main.py +++ b/main.py @@ -115,9 +115,12 @@ def generate_blog_html(posts_per_page=5): # Only process future posts in development mode if front_matter.get("date"): - post_date = datetime.datetime.strptime( - front_matter["date"], "%Y-%m-%d %H:%M:%S" - ) + if isinstance(front_matter["date"], str): + post_date = datetime.datetime.strptime( + front_matter["date"], "%Y-%m-%d %H:%M:%S" + ) + else: + post_date = front_matter["date"] if post_date > datetime.datetime.now(): if not args.dev: print(f"Skipping future post: {post_dir.name}") @@ -184,6 +187,11 @@ def generate_blog_html(posts_per_page=5): # Render each individual post for post in blog_posts: + post.setdefault("license", "CC BY-SA 4.0") + post.setdefault("license-url", "https://creativecommons.org/licenses/by-sa/4.0/") + post.setdefault("author", "Private.coffee Team") + post.setdefault("author-url", "https://private.coffee") + post_slug = post["slug"] render_template_to_file( "blog/post.html",