Unverified Commit ae640cc6 authored by Roland Denis's avatar Roland Denis
Browse files

Fixing highlighted article filter.

Due to empty articles list or containing no valid categories when
generating archives, paginated index or something else...
parent a3db6f2c
Pipeline #3367 passed with stages
in 14 seconds
......@@ -37,7 +37,7 @@ LINKS = (('Pelican', 'http://getpelican.com/'),
# Social widget
SOCIAL = (('@GroupeCalcul', 'https://twitter.com/GroupeCalcul'),)
DEFAULT_PAGINATION = 10
DEFAULT_PAGINATION = False
# Uncomment following line if you want document-relative URLs when developing
#RELATIVE_URLS = True
......
......@@ -26,8 +26,11 @@ def highlighted_article(articles, config):
return next(article for article in reversed(articles) if article.category.slug in config['categories'] and not article.is_finished)
else: # 'date'
return next(article for article in sorted(articles, key=lambda a: a.date, reverse=True) if article.category.slug in config['categories'] and not article.is_finished)
except:
return next(article for article in articles if article.category.slug in config['categories'])
except StopIteration:
try:
return next(article for article in articles if article.category.slug in config['categories'])
except:
return articles[0] # Articles may be empty or not contains any valid category due to pagination, archives, ...
def add_filter(pelican):
......
......@@ -14,12 +14,16 @@
<h1 class="mt-3 mb-2">{{ article.title }}</h1>
<div class="container text-center py-1">
<div class="row d-flex justify-content-center">
{% if article.start_date and article.end_date %}
<div class="col-md-3 header-border px-0">
<span>{{ [article.start_date, article.end_date] | date_interval }}</span>
</div>
{% endif %}
{% if article.place %}
<div class="col-md-3 header-border px-0">
<span>{{ article.place }}</span>
</div>
{% endif %}
<!--
<div class="col-md-3 header-border px-0">
<span>Institut Henri Poincaré</span>
......
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