33 lines
1.4 KiB
Plaintext
33 lines
1.4 KiB
Plaintext
|
|
extends layout
|
|
//- this logic should be moved to a view at some point
|
|
|
|
block content
|
|
- var lineHeight = 2.2;
|
|
- var archives = _.chain(env.helpers.getArticles(contents)).groupBy(function(item) {
|
|
- return item.date.getFullYear();
|
|
- }).value();
|
|
- for (var archive in archives) {
|
|
- archives[archive] = _.groupBy(archives[archive], function(item) { return item.date.getMonth(); });
|
|
- }
|
|
- var month_names = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
|
|
section.archive
|
|
h2 Archive
|
|
ul
|
|
- var yearsK = _.chain(archives).keys().reverse().value();
|
|
each yearK in yearsK
|
|
- var months = archives[yearK];
|
|
- var yearHeight = lineHeight * _.reduce(months, function(memo,month) { return memo + month.length; }, 0);
|
|
li
|
|
span.year-label(style='line-height:' + yearHeight + 'em')= yearK
|
|
ul(style='margin-left:4em')
|
|
- var monthsK = _.chain(months).keys().reverse().value();
|
|
each monthK in monthsK
|
|
- var monthHeight = lineHeight * months[monthK].length;
|
|
li
|
|
span.month-label(style='line-height:' + monthHeight + 'em')= month_names[monthK]
|
|
ul(style='margin-left:7em')
|
|
each item in months[monthK]
|
|
li(style='height:'+ lineHeight + 'em;line-height:' + lineHeight + 'em')
|
|
a(href=item.url)= item.title
|