From 12a40e3be890bb7908b957f3aa3e04f87cd1f02b Mon Sep 17 00:00:00 2001 From: David Soulayrol Date: Sat, 25 Mar 2023 15:07:50 +0100 Subject: [PATCH] Traitement des articles anciens sur le blog. --- assets/production/css/style.css | 15 +++++++++++++++ layouts/blog.njk | 13 +++++++++++-- scripts/metalsmith.js | 11 +++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/assets/production/css/style.css b/assets/production/css/style.css index 0a14c58..72a682b 100644 --- a/assets/production/css/style.css +++ b/assets/production/css/style.css @@ -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; diff --git a/layouts/blog.njk b/layouts/blog.njk index f372c09..28efbaf 100644 --- a/layouts/blog.njk +++ b/layouts/blog.njk @@ -3,12 +3,21 @@ {% block article %}

Actualités

{% block header %}{{ header | safe }}{% endblock %} + {% for article in collections["year"] %}
- {% for article in collections["archives"] %}

{{ date_format(article.date) }} | {{ article.title }}

{{ article.excerpt | safe }}

Lire la suite...

+
+ {% else %} + {% endfor %} +
+ {% for article in collections["archives"] %} + {% else %} {% endfor %} - +
{% endblock %} diff --git a/scripts/metalsmith.js b/scripts/metalsmith.js index cad6708..c413d1a 100644 --- a/scripts/metalsmith.js +++ b/scripts/metalsmith.js @@ -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: {