From a68033df6e21dcc44003895a6509b563ff485c74 Mon Sep 17 00:00:00 2001 From: Jake Charman Date: Tue, 10 Feb 2026 13:49:18 +0000 Subject: [PATCH] Hide posts published in the future --- src/jakecharman/content.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/jakecharman/content.py b/src/jakecharman/content.py index 4286b83..ce9fb63 100755 --- a/src/jakecharman/content.py +++ b/src/jakecharman/content.py @@ -61,15 +61,19 @@ class ContentArea(Blueprint): with self.md_directory.open(p) as f: posts.append(frontmatter.load(f)) return posts + + def get_live_posts(self) -> list: + ''' Get all posts in the posts directory excluding ones with a date in the future ''' + return [x for x in self.get_all_posts() if x.metadata.get('date') <= datetime.now().date()] def get_by_meta_key(self, key: str, value: str) -> list: ''' Get posts by a metadata key value pair ''' - return [x for x in self.get_all_posts() if x.get(key) == value or isinstance(x.get(key, []), list) and value in x.get(key, [])] + return [x for x in self.get_live_posts() if x.get(key) == value or isinstance(x.get(key, []), list) and value in x.get(key, [])] def projects(self) -> str: ''' Load the projects page ''' articles_to_return = sorted( - self.get_all_posts(), + self.get_live_posts(), key=lambda d: d.metadata.get('date'), reverse=True )