From 43c6ce4b4ed7a2336ec57dea155db734064057d6 Mon Sep 17 00:00:00 2001 From: yann Date: Sat, 7 Jun 2025 15:51:11 +0200 Subject: [PATCH] date modification et tri --- _includes/search-loader.html | 19 ++++++++++++++++++- _layouts/category.html | 6 +++++- _layouts/home.html | 7 ++++++- assets/js/data/search.json | 10 ++++++++-- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/_includes/search-loader.html b/_includes/search-loader.html index 7fd065d..db9a3c5 100644 --- a/_includes/search-loader.html +++ b/_includes/search-loader.html @@ -10,6 +10,8 @@
{categories} {tags} + {date} + {datemodif}

{snippet}

@@ -40,9 +42,24 @@ if (value === '') { return `${value}`; } else { - return `
${value}
`; + return `
${value}
`; } } + if (prop === 'date') { + if (value === '') { + return `${value}`; + } else { + return `
${value}
`; + } + } + if (prop === 'datemodif') { + if (value === '') { + return `${value}`; + } else { + return `
${value}
`; + } + } + } }); }); diff --git a/_layouts/category.html b/_layouts/category.html index b064f27..c46e2ba 100644 --- a/_layouts/category.html +++ b/_layouts/category.html @@ -16,8 +16,12 @@ layout: page {% for post in page.posts %}
  • {{ post.title }} - + + {% if post.last_modified_at %} + {% include datetime.html date=post.last_modified_at class='text-muted small text-nowrap' lang=lang %}  + {% endif %} {% include datetime.html date=post.date class='text-muted small text-nowrap' lang=lang %} +
  • {% endfor %} diff --git a/_layouts/home.html b/_layouts/home.html index 451e391..33fffa5 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -86,8 +86,13 @@ refactor: true
    - {% include datetime.html date=post.date lang=lang %} + {% include datetime.html date=post.date lang=lang %} + {% if post.last_modified_at %} + + {% include datetime.html date=post.last_modified_at lang=lang %} + {% endif %} + {% if post.categories.size > 0 %} diff --git a/assets/js/data/search.json b/assets/js/data/search.json index 0b27f2b..a8593a1 100644 --- a/assets/js/data/search.json +++ b/assets/js/data/search.json @@ -4,13 +4,19 @@ swcache: true --- [ - {% for post in site.posts %} + {% assign posts = site.posts | sort: 'last_modified_at' | reverse %} + {% for post in posts %} { "title": {{ post.title | jsonify }}, "url": {{ post.url | relative_url | jsonify }}, "categories": {{ post.categories | join: ', ' | jsonify }}, "tags": {{ post.tags | join: ', ' | jsonify }}, - "date": "{{ post.date }}", + "date": "{{ post.date | date: '%d/%m/%Y' }}", + {% if post.last_modified_at %} + "datemodif": "{{ post.last_modified_at | date: '%d/%m/%Y' }}", + {% else %} + "datemodif": "", + {% endif %} {% include no-linenos.html content=post.content %} {% assign _content = content | strip_html | strip_newlines %} "snippet": {{ _content | truncate: 200 | jsonify }}