Commit d24660d6 authored by berumuron's avatar berumuron
Browse files

Sort articles just before generating the feeds

parent 9b59566f
...@@ -94,11 +94,6 @@ def main(environment): ...@@ -94,11 +94,6 @@ def main(environment):
if serie: if serie:
articles_by_series[serie].append(article) articles_by_series[serie].append(article)
# We want to sort the articles by publication date first
articles.sort(key=lambda article: article.date(), reverse=True)
for serie_articles in articles_by_series.values():
serie_articles.sort(key=lambda article: article.date(), reverse=True)
# Load a "blog" page which has access to the list of articles # Load a "blog" page which has access to the list of articles
blog_template_filepath = os.path.join("templates", "blog.html") blog_template_filepath = os.path.join("templates", "blog.html")
if os.path.exists(blog_template_filepath): if os.path.exists(blog_template_filepath):
......
...@@ -48,6 +48,8 @@ def build_page_from_filepath(filepath, configuration, basename=None, slug=None): ...@@ -48,6 +48,8 @@ def build_page_from_filepath(filepath, configuration, basename=None, slug=None):
def build_blog_page(articles, configuration): def build_blog_page(articles, configuration):
articles.sort(key=lambda article: article.date(), reverse=True)
blog_page = Page("blog", "", configuration=configuration) blog_page = Page("blog", "", configuration=configuration)
blog_page.meta["PAGE_TEMPLATE"] = "blog" blog_page.meta["PAGE_TEMPLATE"] = "blog"
blog_page.meta["ARTICLES"] = articles blog_page.meta["ARTICLES"] = articles
...@@ -90,6 +92,9 @@ def write_feed(feed, output_path): ...@@ -90,6 +92,9 @@ def write_feed(feed, output_path):
feed_filepath = os.path.join(output_path, f"{feed.slug()}.atom.xml") feed_filepath = os.path.join(output_path, f"{feed.slug()}.atom.xml")
articles = feed.articles() articles = feed.articles()
# We want to sort the articles by publication date
articles.sort(key=lambda article: article.date(), reverse=True)
atom = Atom() atom = Atom()
atom.add_header( atom.add_header(
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment