var keystone = require('keystone'),
	_ = require('underscore');

// Load models to allow fetching of slideshow data
var Slideshow = keystone.list('Slideshow'),
	SlideshowItems = keystone.list('Slideshow Item');

exports = module.exports = function(req, res) {
	'use strict';
	
	var view = new keystone.View(req, res),
		locals = res.locals;

	Slideshow.model.find()
		.where('title', 'Main Page Slideshow')
		.exec()
		.then(function (slideshow) {
			
			var slideshowId = slideshow[0].get('_id');

			SlideshowItems.model.find()
				.where('parent', slideshowId)
				.exec()
				.then(function (slides) {

					locals.slides = _.sortBy(slides, function(slide) { return +slide.order; });
					console.log(locals.slides);

					view.render('main');
				});

		});//.then(function() {

		// 	view.render('main');

		// });
	
	// TODO: Get the featured models
};
@@ -684,41 +684,8 @@
  %7D);
-%0A%09%09%09%09%09console.log(locals.slides);
 %0A%0A%09%09

Remove logging messages cluttering the output log.