Commit 89ddf839 authored by berumuron's avatar berumuron
Browse files

Generate pages for article series

If a directory under the article directory contains a `serie.html` file,
we load it as a "serie" page.
parent 72f05132
......@@ -275,19 +275,24 @@ def main(environment):
if os.path.isdir(articles_path):
for filename in dir_tree(articles_path):
filename_no_ext, ext = os.path.splitext(filename)
if ext != ".md":
# Don't consider files which are not Markdown
continue
slug = os.path.basename(filename_no_ext)
# We read the article file and initialize an Article from it
article_filepath = os.path.join(articles_path, filename)
with open(article_filepath, "r") as article_file:
article = Article(
slug, article_file.read(), configuration=configuration
)
articles.append(article)
if slug == "serie" and ext == ".html":
# We have a serie Page! Its slug is the directory name
slug = f"serie/{os.path.dirname(filename)}"
serie_filepath = os.path.join(articles_path, filename)
with open(serie_filepath, "r") as serie_file:
serie = Page(slug, serie_file.read(), configuration=configuration)
pages.append(serie)
elif ext == ".md":
# We read the article file and initialize an Article from it
article_filepath = os.path.join(articles_path, filename)
with open(article_filepath, "r") as article_file:
article = Article(
slug, article_file.read(), configuration=configuration
)
articles.append(article)
# STEP 2: we write all the pages and articles
for page in pages:
......
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