Added sorting and basic refactoring

This commit is contained in:
vanten-s 2023-09-06 09:26:11 +02:00
parent 83a025e6b1
commit 4bba02ea2c
Signed by: vanten-s
GPG key ID: DE3060396884D3F2

View file

@ -39,7 +39,9 @@ def article_to_xml(article_path: pathlib.Path):
return base_item.format(tags="\n".join(tags))
def make_rss_feed(path, channel_name, channel_link, description):
articles = "".join([article_to_xml(path) for path in (pathlib.Path.cwd() / path).glob("*")])
article_paths = (pathlib.Path.cwd() / path).glob("[0-9]*")
article_paths_sorted = sorted(article_paths, key=lambda x: x.name, reverse=True)
articles = "".join([article_to_xml(path) for path in article_paths_sorted])
return base_feed \
.replace("{title}", channel_name) \
.replace("{link}", channel_link) \