Skip to content

Commit 9e8b1b4

Browse files
committed
modified: .github/actions/recent-posts/main.py
- Pulling five most recent blog entries. - Updated regex repl accordingly.
1 parent 342f786 commit 9e8b1b4

File tree

1 file changed

+10
-5
lines changed
  • .github/actions/recent-posts

1 file changed

+10
-5
lines changed

.github/actions/recent-posts/main.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def link(self: "Entry") -> HttpUrl:
3535
class Feed(BaseXmlModel, tag="feed", nsmap=NSMAP, search_mode="ordered"):
3636
"""Validate the RSS feed/XML from my blog."""
3737

38-
# We limit to the first <entry> from the RSS feed as it is the most
39-
# recently published.
40-
entry: Entry
38+
# We limit to the first five <entry> from the RSS feed as they are
39+
# the most recently published.
40+
entries: tuple[Entry, Entry, Entry, Entry, Entry]
4141

4242

4343
@app.command()
@@ -56,8 +56,13 @@ def main(
5656
text = f.read()
5757

5858
pattern = r"(?<=<!-- BLOG START -->)[\S\s]*(?=<!-- BLOG END -->)"
59-
repl = (
60-
f"- [{model.entry.title}]({model.entry.link}) by {model.entry.author}"
59+
template = "- [{title}]({link}) by {author}"
60+
repl = "\n".join(
61+
[
62+
template.format(
63+
title=entry.title, link=entry.link, author=entry.author
64+
) for entry in model.entries
65+
]
6166
)
6267
new_text = re.sub(pattern=pattern, repl=f"\n{repl}\n", string=text)
6368
with readme.open(mode="w") as f:

0 commit comments

Comments
 (0)