From f2a59977c5c9403dd5d2525e325e4ee59ebeeb21 Mon Sep 17 00:00:00 2001 From: Jim Bumgardner Date: Thu, 5 Sep 2024 20:52:16 -0700 Subject: [PATCH] Inhibit display of earlier-than 2022 blog posts on blog index page. --- .eleventy.js | 6 ++++++ pages/_includes/all-posts.njk | 3 +++ 2 files changed, 9 insertions(+) diff --git a/.eleventy.js b/.eleventy.js index 359ab2faa..ae106120e 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -73,6 +73,12 @@ module.exports = function (eleventyConfig) { return `${d.getMonth() + 1}/${d.getDate()}/${d.getFullYear()}`; }); + eleventyConfig.addFilter("dateyear", function (dateString) { + const d = new Date(dateString); + return d.getFullYear(); + }); + + eleventyConfig.addFilter('includes', (items, value) => { return (items || []).includes(value); }); diff --git a/pages/_includes/all-posts.njk b/pages/_includes/all-posts.njk index 4b94f709d..629c31097 100644 --- a/pages/_includes/all-posts.njk +++ b/pages/_includes/all-posts.njk @@ -8,11 +8,14 @@
{%- for post in collections.dateSort -%} + + {% if (post.data.publishdate | dateyear) >= 2022 %}

{{ post.data.title | safe }}

{{ post.data.publishdate | dateformat }}

{{ post.data.meta | safe }} + {% endif %} {%- endfor -%}