Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inhibit display of earlier-than 2022 blog posts on blog index page. #349

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
3 changes: 3 additions & 0 deletions pages/_includes/all-posts.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

<div class="cagov-article-list row">
{%- for post in collections.dateSort -%}
<!-- check if date is older than 2022 -->
{% if (post.data.publishdate | dateyear) >= 2022 %}
<h2 class="h3" class="cagov-mt-3">
<a href="{{ post.url }}">{{ post.data.title | safe }}</a>
</h2>
<p class="text-mute">{{ post.data.publishdate | dateformat }}</p>
<span class="blog-excerpt">{{ post.data.meta | safe }}</span>
{% endif %}
{%- endfor -%}
</div>
</main>
Expand Down