summaryrefslogtreecommitdiff
path: root/build.py
diff options
context:
space:
mode:
Diffstat (limited to 'build.py')
-rwxr-xr-xbuild.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/build.py b/build.py
index 6505dbb..3b53963 100755
--- a/build.py
+++ b/build.py
@@ -28,9 +28,11 @@ class Post:
date: str
content: str
path: str
+ tags: list
posts = []
+tags = []
for post in os.listdir(__here__ / "posts"):
if len(post) < 3:
continue
@@ -43,10 +45,15 @@ for post in os.listdir(__here__ / "posts"):
kwargs["date"] = md.Meta["date"][0]
kwargs["content"] = content
kwargs["path"] = post[:-3]
+ kwargs["tags"] = md.Meta.get("tags", [""])[0].split()
+ tags += kwargs["tags"]
posts.append(Post(**kwargs))
posts.sort(key=lambda p: p.date, reverse=True)
+tags = list(set(tags))
+tags.sort()
+
# index -------------------------------------------------------------------------------------------
@@ -75,6 +82,19 @@ for post in posts:
f.write(template.render(post=post, title=post.title, date=date))
+# tags --------------------------------------------------------------------------------------------
+
+
+
+template = env.get_template("tags.html")
+if not os.path.isdir(__here__ / "public" / "tags"):
+ os.mkdir(__here__ / "public" / "tags")
+with open(__here__ / "public" / "tags" / "index.html", "w") as f:
+ f.write(template.render(posts=posts, tags=tags, title="tags", date=date))
+
+
+
+
# css ---------------------------------------------------------------------------------------------