Skip to content

Commit 4d1d1b1

Browse files
committed
rss too
1 parent 6f2df32 commit 4d1d1b1

File tree

2 files changed

+14
-76
lines changed

2 files changed

+14
-76
lines changed

Diff for: generate-html.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
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
64
from datetime import date, datetime
75
from email.utils import formatdate, format_datetime # for RFC2822 formatting
6+
from pathlib import Path
7+
8+
import jinja2
9+
import markdown
810

911
TEMPLATE_FILE = "templates/blog_post_template.html"
1012
FEED_TEMPLATE_FILE = "templates/rss_feed_template.xml"
1113
BLOG_POSTS_PATH = Path("posts")
1214
OUTPUT_DIR = Path("_site")
1315

14-
from dataclasses import dataclass
16+
1517

1618
@dataclass
1719
class 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

7583
if __name__ == "__main__":

Diff for: rss.xml

-70
This file was deleted.

0 commit comments

Comments
 (0)