Permalink
Browse files

added ascending/descending arrays

  • Loading branch information...
1 parent d6ae59a commit b23ea606b68c407c3b9428d06ea0286cbc3199d8 @olegp committed Oct 20, 2011
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/mcms.js
View
@@ -19,7 +19,7 @@ var MIME_TYPES = {
".zip": "application/zip"
};
-var pages = {}, templates = {}, includes = {}, list = [];
+var pages = {}, templates = {}, includes = {}, ascending = [], descending;
function friendly(url) {
return url.toLowerCase() //
@@ -61,10 +61,12 @@ fs.listTree(PAGES).splice(1).forEach(function(file) {
link: link,
modified: fs.lastModified(file)
};
- list.unshift(pages[link] = page);
+ ascending.push(pages[link] = page);
}
});
+descending = ascending.slice().reverse();
+
fs.listTree(TEMPLATES).splice(1).forEach(function(file) {
var path = fs.join(TEMPLATES, file);
if(!fs.isDirectory(path)) {
@@ -113,7 +115,9 @@ exports.app = function(request) {
page.body = mustache(template, merge({
// TODO deal with case when title == 'index'
title: page.title,
- body: markdown(md)
+ body: markdown(md),
+ ascending: ascending,
+ descending: descending
}, includes));
}
return {

0 comments on commit b23ea60

Please sign in to comment.