Commit 1c676f10 authored by berumuron's avatar berumuron
Browse files

tec: Change the datastructure to store articles

parent 8bc44bb5
......@@ -29,7 +29,7 @@ def main(environment):
# STEP 1: we load all the Articles, Pages and Feeds
pages = []
series = []
articles = []
articles = {}
feeds = []
# Check that index file exists
......@@ -76,7 +76,7 @@ def main(environment):
article = utils.build_article_from_filepath(
article_filepath, configuration, serie
)
articles.append(article)
articles[article_filepath] = article
serie_articles.append(article)
if serie:
......@@ -105,7 +105,7 @@ def main(environment):
# And load the main feed
if len(articles) > 0 or configuration.get("SITE_FORCE_FEED", False):
feed = Feed("feeds/all", articles, configuration=configuration)
feed = Feed("feeds/all", list(articles.values()), configuration=configuration)
feeds.append(feed)
# STEP 2: we write all the pages, articles and feeds
......@@ -113,8 +113,9 @@ def main(environment):
utils.write_content(page, output_path)
print(f"Written page: {page.url()}")
articles.sort(key=lambda article: article.date(), reverse=True)
for article in articles:
articles_sorted = list(articles.values())
articles_sorted.sort(key=lambda article: article.date(), reverse=True)
for article in articles_sorted:
utils.write_content(article, output_path)
print(f"Written article: {article.url()}")
......
......@@ -49,7 +49,7 @@ def build_page_from_filepath(filepath, configuration, basename=None, slug=None):
def build_blog_page(articles, series, configuration):
articles = [article for article in articles if not article.is_private()]
articles = [article for article in articles.values() if not article.is_private()]
articles.sort(key=lambda article: article.date(), reverse=True)
series.sort(key=lambda serie: serie.title(), reverse=False)
......
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