File tree 2 files changed +14
-76
lines changed
2 files changed +14
-76
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
2
# 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
6
4
from datetime import date , datetime
7
5
from email .utils import formatdate , format_datetime # for RFC2822 formatting
6
+ from pathlib import Path
7
+
8
+ import jinja2
9
+ import markdown
8
10
9
11
TEMPLATE_FILE = "templates/blog_post_template.html"
10
12
FEED_TEMPLATE_FILE = "templates/rss_feed_template.xml"
11
13
BLOG_POSTS_PATH = Path ("posts" )
12
14
OUTPUT_DIR = Path ("_site" )
13
15
14
- from dataclasses import dataclass
16
+
15
17
16
18
@dataclass
17
19
class Post :
@@ -67,9 +69,15 @@ def main():
67
69
68
70
# Order blog posts by date published
69
71
all_posts .sort (key = lambda p : p .date , reverse = True )
72
+
70
73
# 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
+ )
73
81
74
82
75
83
if __name__ == "__main__" :
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments