Skip to content

Instantly share code, notes, and snippets.

@ruemic
Last active December 23, 2015 11:39
Show Gist options
  • Save ruemic/6629785 to your computer and use it in GitHub Desktop.
Save ruemic/6629785 to your computer and use it in GitHub Desktop.
A Webpop extension for rendering entries that occurred in the past.
exports.past_months = function(options) {
if (!section) return null;
var result = site.search({
all: true,
filters: {section: section, date: "past" },
timeline: {date: "month"},
}).timeline;
return result;
// Returns a simple array of months with 'start' & 'end' atrributes
};
// Generates an array of entries who's 'date' field falls
// within the specified 'start' and 'end' date.
exports.past_entries_for = function(options) {
if (!section) return null;
var start = new Date(options.start), end = new Date(options.end);
if ( new Date() < end )
end = new Date()
var results = site.search({
all: true,
filters: {section: section, date: {from: start, to: end}},
order: "date DESC"
}).results;
return results;
// Returns an array of tour dates which you can render out
// in your templates like a regular collection tag.
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment