-
Notifications
You must be signed in to change notification settings - Fork 50
/
blog-by-year.njk
40 lines (35 loc) · 1.15 KB
/
blog-by-year.njk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---
title: Blog posts by year
pagination:
data: global.years
size: 1
alias: year
permalink: /blog/{{ year }}/
---
{% extends 'layouts/base.njk' %}
{# Intro content #}
{% set introHeading %}Posts published in {{ year }}{% endset %}
{% set introHeadingLevel = '2' %}
{# Post list content #}
{% set postListHeadingLevel = '2' %}
{% set postListItems = helpers.filterPostsByYear(collections.posts, year) %}
{% set postListHeading = postListItems.length +' posts' %}
{# Pagination #}
{% if year > global.years | first %}
{% set paginationPrevText = 'Posts in ' + (year - 1) %}
{% set paginationPrevUrl = pagination.href.previous %}
{% endif %}
{% if year < global.years | last %}
{% set paginationNextText = 'Posts in ' + (year + 1) %}
{% set paginationNextUrl = pagination.href.next %}
{% endif %}
{% block content %}
<main id="main-content" tabindex="-1">
{% include "partials/components/intro.njk" %}
{% if postListItems.length == 0 %}
<div class="inner-wrapper"><p>No posts found.</p></div>
{% endif %}
{% include "partials/components/post-list.njk" %}
{% include "partials/components/pagination.njk" %}
</main>
{% endblock %}