Centralize the number of posts to show to front matter
This commit is contained in:
parent
ed48ef453d
commit
9fa7458062
@ -3,17 +3,19 @@ layout: layouts/home.njk
|
|||||||
eleventyNavigation:
|
eleventyNavigation:
|
||||||
key: Home
|
key: Home
|
||||||
order: 1
|
order: 1
|
||||||
|
numberOfLatestPostsToShow: 3
|
||||||
---
|
---
|
||||||
{% set postsCount = collections.posts | length %}
|
{% set postsCount = collections.posts | length %}
|
||||||
{% set latestPostsCount = postsCount | min(3) %}
|
{% set latestPostsCount = postsCount | min(numberOfLatestPostsToShow) %}
|
||||||
<h1>Latest {{ latestPostsCount }} Post{% if latestPostsCount != 1 %}s{% endif %}</h1>
|
<h1>Latest {{ latestPostsCount }} Post{% if latestPostsCount != 1 %}s{% endif %}</h1>
|
||||||
|
|
||||||
{% set postslist = collections.posts | head(-3) %}
|
{% set postslist = collections.posts | head(-1 * numberOfLatestPostsToShow) %}
|
||||||
{% set postslistCounter = postsCount %}
|
{% set postslistCounter = postsCount %}
|
||||||
{% include "postslist.njk" %}
|
{% include "postslist.njk" %}
|
||||||
|
|
||||||
{% if postsCount > 3 %}
|
{% set morePosts = postsCount - numberOfLatestPostsToShow %}
|
||||||
<p>More posts can be found in <a href="/blog/">the archive</a>.</p>
|
{% if morePosts > 0 %}
|
||||||
|
<p>{{ morePosts }} more post{% if morePosts != 1 %}s{% endif %} can be found in <a href="/blog/">the archive</a>.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# List every content page in the project #}
|
{# List every content page in the project #}
|
||||||
|
Loading…
Reference in New Issue
Block a user