File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22# copied from https://github.com/tonybaloney/tonybaloney.github.io/blob/master/blog-gen.py
3- import markdown
4- import jinja2
5- from pathlib import Path
3+ from dataclasses import dataclass
64from datetime import date , datetime
75from email .utils import formatdate , format_datetime # for RFC2822 formatting
6+ from pathlib import Path
7+
8+ import jinja2
9+ import markdown
810
911TEMPLATE_FILE = "templates/blog_post_template.html"
1012FEED_TEMPLATE_FILE = "templates/rss_feed_template.xml"
1113BLOG_POSTS_PATH = Path ("posts" )
1214OUTPUT_DIR = Path ("_site" )
1315
14- from dataclasses import dataclass
16+
1517
1618@dataclass
1719class Post :
@@ -67,9 +69,15 @@ def main():
6769
6870 # Order blog posts by date published
6971 all_posts .sort (key = lambda p : p .date , reverse = True )
72+
7073 # Make the RSS feed
71- with open ("rss.xml" , "w" ) as rss_f :
72- rss_f .write (env .get_template (FEED_TEMPLATE_FILE ).render (posts = all_posts , date = formatdate ()))
74+ rss_path = OUTPUT_DIR / "rss.xml"
75+ print ("writing" , rss_path )
76+ rss_path .write_text (
77+ env .get_template (FEED_TEMPLATE_FILE ).render (
78+ posts = all_posts , date = formatdate ()
79+ )
80+ )
7381
7482
7583if __name__ == "__main__" :
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments