Skip to content

Commit

Permalink
allow to not specify category metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Clément committed Jul 16, 2024
1 parent b211d39 commit 2bccd0a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions jssg/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ def __init__(self, content: str, **metadata) -> None:
"""
super().__init__(content, **metadata)
self.timestamp = datetime.datetime.fromisoformat(metadata["date"])
self.metadata["category"] = slugify(self.metadata["category"])
if "category" in self.metadata :
self.metadata["category"] = slugify(self.metadata["category"])
else :
self.metadata["category"] = ""

@classmethod
def load_glob(
Expand Down Expand Up @@ -310,8 +313,9 @@ def load_post_list_with_category(cls, category) :
def categories(self) :
cat = set()
for post in Post.load_glob(all = True) :
cat.add(post.metadata["category"])
return list(cat)
if post.metadata["category"] != "" :
cat.add(post.metadata["category"])
return cat

@classmethod
def get_categories(cls) :
Expand Down

0 comments on commit 2bccd0a

Please sign in to comment.