Skip to content

Instantly share code, notes, and snippets.

@ruemic
Last active December 16, 2015 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruemic/5494041 to your computer and use it in GitHub Desktop.
Save ruemic/5494041 to your computer and use it in GitHub Desktop.
Some comments to describe the inner workings of a Webpop calendar extension
// This searches the entries of a section to generates a simple
// timeline object that represents all the years which entries
// with a date in the future belong to.
exports.years= function() {
if (!section) return null;
var result = site.search({
all: true,
filters: {section: section, date: "future"},
timeline: {date: "year"},
}).timeline;
return result;
// Returns a simple array of years with 'start' & 'end' atrributes
}
// This searches the entries to generate a simple timeline
// object which represents all the months which have entries,
// and occur within the specified 'start' and 'end' date.
exports.months = function(options) {
if (!section) return null;
var start = new Date(options.start), end = new Date(options.end);
var result = site.search({
all: true,
filters: {section: section, date: {from: start, to: end}},
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.entries_for = function(options) {
if (!section) return null;
var start = new Date(options.start), end = new Date(options.end);
var results = site.search({
all: true,
filters: {section: section, date: {from: start, to: end}},
order: "date ASC"
}).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