File tree Expand file tree Collapse file tree 4 files changed +19
-12
lines changed Expand file tree Collapse file tree 4 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ module.exports = function(config) {
26
26
config . addLayoutAlias ( 'home' , 'layouts/home.njk' ) ;
27
27
config . addLayoutAlias ( 'post' , 'layouts/post.njk' ) ;
28
28
config . addLayoutAlias ( 'page' , 'layouts/page.njk' ) ;
29
+ config . addLayoutAlias ( 'archive' , 'layouts/archive.njk' ) ;
29
30
30
31
// Transforms
31
32
config . addTransform ( 'htmlmin' , htmlMinTransform ) ;
Original file line number Diff line number Diff line change 1
- const thisYear = new Date ( ) . getFullYear ( ) ;
2
- const years = [ ] ;
3
- // my blog started in 2008
4
- for ( let y = 2008 ; y <= thisYear ; y ++ ) {
5
- years . push ( y ) ;
6
- }
7
-
1
+ /* eslint-disable no-bitwise */
8
2
module . exports = {
9
- years,
3
+ get years ( ) {
4
+ const thisYear = new Date ( ) . getFullYear ( ) ;
5
+ const years = [ ] ;
6
+ // my blog started in 2008
7
+ for ( let y = 2008 ; y <= thisYear ; y ++ ) {
8
+ years . push ( y ) ;
9
+ }
10
+
11
+ return years ;
12
+ } ,
10
13
random ( ) {
11
14
const segment = ( ) => {
12
15
return ( ( ( 1 + Math . random ( ) ) * 0x10000 ) | 0 ) . toString ( 16 ) . substring ( 1 ) ;
Original file line number Diff line number Diff line change @@ -14,23 +14,26 @@ permalink: /blog/{{ year }}/
14
14
15
15
{# Post list content #}
16
16
{% set postListHeadingLevel = ' 2' %}
17
- {% set postListHeading = ' Posts' %}
18
17
{% set postListItems = helpers .filterPostsByYear (collections .posts , year ) %}
18
+ {% set postListHeading = postListItems .length + ' posts' %}
19
19
20
20
{# Pagination #}
21
21
{% if year > global .years | first %}
22
22
{% set paginationPrevText = ' Posts in ' + (year - 1) %}
23
- {% set paginationPrevUrl %} /blog/ {{ year - 1 }} / {% endset %}
23
+ {% set paginationPrevUrl = pagination . href . previous %}
24
24
{% endif %}
25
25
{% if year < global .years | last %}
26
26
{% set paginationNextText = ' Posts in ' + (year + 1) %}
27
- {% set paginationNextUrl %} /blog/ {{ year + 1 }} / {% endset %}
27
+ {% set paginationNextUrl = pagination . href . next %}
28
28
{% endif %}
29
29
30
30
31
31
{% block content %}
32
32
<main id =" main-content" tabindex =" -1" >
33
33
{% include " partials/components/intro.njk" %}
34
+ {% if postListItems .length == 0 %}
35
+ <div class =" inner-wrapper" ><p >No posts found.</p ></div >
36
+ {% endif %}
34
37
{% include " partials/components/post-list.njk" %}
35
38
{% include " partials/components/pagination.njk" %}
36
39
</main >
Original file line number Diff line number Diff line change 1
1
---
2
2
title : ' Blog'
3
- layout : ' layouts/ archive.njk '
3
+ layout : ' archive'
4
4
---
You can’t perform that action at this time.
0 commit comments