Router.configure({
    layoutTemplate : 'layout',
    loadingTemplate : 'loading',
    notFoundTemplate : 'notFound'
    // waitOn : function () {
    //     return Meteor.subscribe('posts');
    // }
});

Router.route('/', {name : 'landing'});
Router.route('/goalsettings', {name : 'showGoals'});
Router.route('/crylevel', {name : 'cryLevel'});

Router.route('/posts/:_id', {
    name : 'postPage',
    data : function() {
        return Posts.findOne(this.params._id);
    }
});

Router.route('/posts/:_id/edit', {
    name : 'postEdit',
    data : function () {
        return Posts.findOne(this.params._id);
    }
})

Router.route('/submit', {name : 'postSubmit'})

var requireLogin = function () {
    if (!Meteor.userId()) {
        if (Meteor.loggingIn()) {
            this.render('loadingTemplate');
        } else {
            Router.go('landing');
        }
        this.stop();
    } else {
        this.next();
    }
}

Router.onBeforeAction('dataNotFound', {only : 'postPage'});
Router.onBeforeAction(requireLogin, {except : 'landing'});
@@ -257,16 +257,17 @@
 e('/goal
+-
 settings
@@ -310,16 +310,17 @@
 te('/cry
+-
 level', 

Add dashes to route paths