Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

Commit

Permalink
Use created instead of date
Browse files Browse the repository at this point in the history
  • Loading branch information
pvorb committed Feb 16, 2012
1 parent 585ca16 commit b5d7348
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions bread.js
Expand Up @@ -37,28 +37,35 @@ var bread = function(conf, cb) {
reg.tags = new Set();

// Parse contents with `marked()`
hooks.__content = function(f, prop, cb) {
hooks.__content = function __content(f, prop, cb) {
pandoc(prop.__content, 'markdown', 'html', cb);
};

hooks.__propBefore = function __propBefore(f, prop, cb) {
if (!prop.modified)
prop.modified = new Date();

cb(null, prop);
};

// Parse ISO 8601 dates
hooks.date = function(f, prop, cb) {
var date;
hooks.created = function(f, prop, cb) {
var created;
// If it's not a date, try parse it
if (typeof prop.date != 'date') {
if (typeof prop.created != 'date') {
try {
date = isodate(prop.date);
created = isodate(prop.created);
} catch (err) {
try {
date = new Date(prop.date);
created = new Date(prop.created);
} catch (err) {
return cb(err);
}
}
} else
date = prop.date;
created = prop.created;

cb(null, date)
cb(null, created);
};

// Save files in registry
Expand Down

0 comments on commit b5d7348

Please sign in to comment.