Try to sort articles, based on their published_dates

This commit is contained in:
Fred Pauchet 2023-01-10 21:48:33 +01:00
parent 74a5faae48
commit 04736aa405
3 changed files with 20 additions and 4 deletions

View File

@ -72,11 +72,27 @@ class Article:
class PublishedUnpublished:
@property
def published_articles(self):
return [x for x in self.articles if x.published_date]
results = [x for x in self.articles if x.published_date]
sorted(
results,
key=lambda x: x.pubished_date,
reverse=True,
)
return results
@property
def articles_without_date(self):
return [x for x in self.articles if not x.published_date]
results = [x for x in self.articles if not x.published_date]
sorted(
results,
key=lambda x: x.pubished_date,
reverse=True,
)
return results
class Section(PublishedUnpublished):

View File

@ -7,7 +7,7 @@
</ul>
<ul>
{% for year, list in site.published_articles|groupby('published_date.year') %}
{% for year, list in site.published_articles|reverse|groupby('published_date.year') %}
<li><b>{{ year }}</b>
<ul>
{% for event in list %}

View File

@ -1,7 +1,7 @@
<h1>{{ section.parent.key }} >> {{ section.key }}</h1>
<ul>
{% for year, list in section.published_articles|groupby('published_date.year') %}
{% for year, list in section.published_articles|reverse|groupby('published_date.year') %}
<li><b>{{ year }}</b>
<ul>
{% for event in list %}