summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blog/feed.py6
-rw-r--r--blog/post.py1
-rw-r--r--posts/hello-world/metadata.txt1
-rw-r--r--templates/post.html11
4 files changed, 15 insertions, 4 deletions
diff --git a/blog/feed.py b/blog/feed.py
index d8ffc8c..a63ee77 100644
--- a/blog/feed.py
+++ b/blog/feed.py
@@ -6,7 +6,11 @@ import render
class Feed(object):
def __init__(self, template, posts):
self.template = template
- self.posts = posts
+ self.posts = Feed._remove_drafts(posts)
+
+ @staticmethod
+ def _remove_drafts(posts):
+ return list(filter(lambda x: x.metadata.status != "draft", posts))
def generate(self, basedir):
index = os.path.join(basedir, "index.html")
diff --git a/blog/post.py b/blog/post.py
index ebf2e4c..54440ff 100644
--- a/blog/post.py
+++ b/blog/post.py
@@ -63,6 +63,7 @@ class Post(object):
content = render.to_html(md)
rendered = self.template.render(title=self.metadata.title,
date=self.metadata.date,
+ status=self.metadata.status,
content=content)
render.write_file_content(os.path.join(workdir, "index.html"),
rendered)
diff --git a/posts/hello-world/metadata.txt b/posts/hello-world/metadata.txt
index 3333eb3..e3057c4 100644
--- a/posts/hello-world/metadata.txt
+++ b/posts/hello-world/metadata.txt
@@ -1,2 +1,3 @@
Title: Hello, World!
Date: 2022-12-23
+Status: published
diff --git a/templates/post.html b/templates/post.html
index 8da33b2..56bdef8 100644
--- a/templates/post.html
+++ b/templates/post.html
@@ -20,9 +20,14 @@
<main>
<h1>{{ title }}</h1>
-<p><i><time datetime="{{ date }}" pubdate>
-{{ date }}
-</time></i></p>
+<p>
+ <i><time datetime="{{ date }}" pubdate>
+ {{ date }}
+ </time></i>
+{% if status == "draft" %}
+• {{ status }}
+{% endif %}
+</p>
<content>
{{ content|safe }}