Hide posts published in the future
This commit is contained in:
@@ -62,14 +62,18 @@ class ContentArea(Blueprint):
|
|||||||
posts.append(frontmatter.load(f))
|
posts.append(frontmatter.load(f))
|
||||||
return posts
|
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:
|
def get_by_meta_key(self, key: str, value: str) -> list:
|
||||||
''' Get posts by a metadata key value pair '''
|
''' 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:
|
def projects(self) -> str:
|
||||||
''' Load the projects page '''
|
''' Load the projects page '''
|
||||||
articles_to_return = sorted(
|
articles_to_return = sorted(
|
||||||
self.get_all_posts(),
|
self.get_live_posts(),
|
||||||
key=lambda d: d.metadata.get('date'),
|
key=lambda d: d.metadata.get('date'),
|
||||||
reverse=True
|
reverse=True
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user