Commit 4ca1ff06 authored by berumuron's avatar berumuron
Browse files

Refactor dirs with articles listing

parent 9a2c6459
......@@ -331,19 +331,20 @@ def main(environment):
# We iterate on the directories of articles dir. If they contain
# "serie.html" file, it means they contain a serie. Otherwise, we list
# articles as usual.
for dirname in list_dirs(articles_path):
dirpath = os.path.join(articles_path, dirname)
dirs_with_articles = list(list_dirs(articles_path)) + ["."]
for dirname in dirs_with_articles:
dirpath = os.path.realpath(os.path.join(articles_path, dirname))
serie_filepath = os.path.join(dirpath, "serie.html")
serie = None
if os.path.exists(serie_filepath):
if dirname != "." and os.path.exists(serie_filepath):
# We have a serie Page! Each article of the directory must be
# considered part of the serie.
slug = f"serie/{dirname}"
with open(serie_filepath, "r") as serie_file:
serie = Page(slug,, configuration=configuration)
articles_by_series[serie] = []
articles_by_series[serie] = []
for filename in list_files(dirpath, only=["md"]):
article_filepath = os.path.join(dirpath, filename)
......@@ -354,11 +355,6 @@ def main(environment):
if serie:
for filename in list_files(articles_path, only=["md"]):
article_filepath = os.path.join(articles_path, filename)
article = build_article_from_filepath(article_filepath, configuration)
# STEP 2: we write all the pages and articles
for page in pages:
output_filepath = os.path.join(output_path, f"{page.slug()}.html")
Supports Markdown
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