var path = require('path');
module.exports = function(config) {
  var postMaker = require('./maker/post')(config);
  var urlMaker = require('./maker/url')(config);
  var pagination = require('./tool/pagination')(config);
  return function(posts) {
    var archives = {};
    posts.forEach(function(post) {
      var date = new Date(post.date);
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      archives[year] = archives[year] || {};
      archives[year][month] = archives[year][month] || [];
      archives[year][month].push(post);
    });
    var result = [];
    for (var year in archives)
      for (var month in archives[year])[].push.apply(result, pagination({
        path: path.join(urlMaker.archives, year, month, 'list.json'),
        data: {
          posts: archives[year][month].map(function(post) {
            return postMaker(post, true);
          })
        }
      }));
    return result;
  };
};
@@ -656,16 +656,27 @@
 s%5Byear%5D)
+ %7B%0A        
 %5B%5D.push.
@@ -702,16 +702,18 @@
 ation(%7B%0A
+  
         
@@ -786,16 +786,18 @@
     
+  
 data: %7B%0A
     
@@ -792,16 +792,68 @@
 data: %7B%0A
+            year: year,%0A            month: month,%0A  
         
@@ -912,24 +912,26 @@
             
+  
 return postM
@@ -962,11 +962,15 @@
     
+  
 %7D)%0A
+  
     
@@ -985,13 +985,23 @@
     
+  
 %7D));%0A
+      %7D%0A
     

add year and month to archive