1
0
forked from ti-nuage/site

Traitement des articles anciens sur le blog.

This commit is contained in:
David Soulayrol
2023-03-25 15:07:50 +01:00
parent d22e2e81a3
commit 12a40e3be8
3 changed files with 37 additions and 2 deletions

View File

@@ -95,6 +95,21 @@ abbr {
border-bottom: 1px dotted #373d3f;
}
.archives {
display: flex;
flex-wrap: wrap;
}
.archives article {
padding-left: 1em;
padding-right: 1em;
width: calc(50% - 2em);
}
.archives article h2 {
font-size: 1.2em;
}
.loader-wrapper {
display: grid;
grid-template-columns: 1fr 4fr;

View File

@@ -3,12 +3,21 @@
{% block article %}
<h1 class="mt128">Actualités</h1>
{% block header %}{{ header | safe }}{% endblock %}
{% for article in collections["year"] %}
<article>
{% for article in collections["archives"] %}
<h2><a href="/{{ article.path }}">{{ date_format(article.date) }} | {{ article.title }}</a></h2>
{{ article.excerpt | safe }}
<p><a href="/{{ article.path }}">Lire la suite...</a></p>
</article>
{% else %}
{% endfor %}
<div class="archives mt64">
{% for article in collections["archives"] %}
<article>
<h2><a href="/{{ article.path }}">{{ date_format(article.date) }} | {{ article.title }}</a></h2>
{{ article.excerpt | safe }}
</article>
{% else %}
{% endfor %}
</article>
</div>
{% endblock %}

View File

@@ -95,6 +95,17 @@ module.exports = new Metalsmith(config.paths.projectRoot)
archives: {
pattern: 'blog/*/**/*/*.html',
reverse: true,
filterBy: (article) => {
return new Date(article.date).getFullYear() !== new Date().getFullYear()
},
sortBy: 'date'
},
year: {
pattern: 'blog/*/**/*/*.html',
reverse: true,
filterBy: (article) => {
return new Date(article.date).getFullYear() === new Date().getFullYear()
},
sortBy: 'date'
},
news: {