diff options
Diffstat (limited to 'build.py')
-rwxr-xr-x | build.py | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -1,5 +1,4 @@ import os -from pprint import pprint import jinja2 import markdown import pathlib @@ -13,7 +12,7 @@ __here__ = pathlib.Path(__file__).resolve().parent date = datetime.now().strftime('%Y-%m-%d %H:%M:%S') -md = markdown.Markdown(extensions=['meta']) +md = markdown.Markdown(extensions=['meta', "toc"]) env = jinja2.Environment(loader = jinja2.FileSystemLoader(str(__here__ / "templates"))) @@ -39,7 +38,6 @@ for post in os.listdir(__here__ / "posts"): kwargs["date"] = md.Meta["date"][0] kwargs["content"] = content kwargs["path"] = post[:-3] - print(kwargs) posts.append(Post(**kwargs)) posts.sort(key=lambda p: p.date, reverse=True) @@ -62,6 +60,7 @@ with open(__here__ / "public" / "index.html", "w") as f: template = env.get_template("post.html") for post in posts: + print(post.path) if not os.path.isdir(__here__ / "public" / post.path): os.mkdir(__here__ / "public" / post.path) with open(__here__ / "public" / post.path / "index.html", "w") as f: @@ -73,5 +72,5 @@ for post in posts: template = env.get_template('style.css') for d, _, _ in os.walk(__here__ / "public", topdown=False): - with open(os.path.join(d, "style.css"), 'w') as fh: - fh.write(template.render()) + with open(os.path.join(d, "style.css"), 'w') as f: + f.write(template.render()) |