Commit db113d6b authored by berumuron's avatar berumuron
Browse files

Give access to series in blog template

parent 0132472c
......@@ -389,6 +389,9 @@ feed obviously contains only the articles from the serie. You can also access
the serie object from the article template with `ARTICLE_SERIE`. The two most
interesting functions to use on this object are `title()` and `url()`.
Series are accessible through the `blog` template with the `SERIES` variable. A
serie is just a basic page.
To finish, you can create a template specific to series. For that, you'll have
to set a `template: serie` variable in your `serie.html` files. The series have
access to two additional variables: `ARTICLES` (such in the `blog` template but
......@@ -40,6 +40,7 @@ def main(environment):
# STEP 1: we load all the Articles, Pages and Feeds
pages = []
series = []
articles = []
feeds = []
......@@ -80,7 +81,7 @@ def main(environment):
serie = utils.build_page_from_filepath(
serie_filepath, configuration, slug=slug
# Let's collect all the articles from the directory
serie_articles = []
......@@ -112,7 +113,7 @@ def main(environment):
# Load a "blog" page which has access to the list of articles
blog_template_filepath = os.path.join("templates", "blog.html")
if os.path.exists(blog_template_filepath):
blog_page = utils.build_blog_page(articles, configuration)
blog_page = utils.build_blog_page(articles, series, configuration)
# And load the main feed
......@@ -121,7 +122,7 @@ def main(environment):
# STEP 2: we write all the pages, articles and feeds
for page in pages:
for page in pages + series:
utils.write_content(page, output_path)
print(f"Written page: {page.url()}")
......@@ -47,8 +47,9 @@ def build_page_from_filepath(filepath, configuration, basename=None, slug=None):
return Page(final_slug,, configuration=configuration)
def build_blog_page(articles, configuration):
def build_blog_page(articles, series, configuration):
articles.sort(key=lambda article:, reverse=True)
series.sort(key=lambda serie: serie.title(), reverse=False)
blog_page = Page("blog", "", configuration=configuration)
blog_page.meta["PAGE_TEMPLATE"] = "blog"
......@@ -56,6 +57,7 @@ def build_blog_page(articles, configuration):
blog_page.meta["ARTICLES_BY_YEAR"] = itertools.groupby(
articles, key=lambda article:
blog_page.meta["SERIES"] = series
return blog_page
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