0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00
ghost/core/frontend/controllers/index.js

30 lines
793 B
JavaScript
Raw Normal View History

2013-05-11 11:44:25 -05:00
/**
* Main controller for Ghost frontend
*/
/*global require, module */
var Ghost = require('../../ghost'),
api = require('../../shared/api'),
2013-05-11 11:44:25 -05:00
ghost = new Ghost(),
frontendControllers;
2013-05-11 11:44:25 -05:00
frontendControllers = {
'homepage': function (req, res) {
api.posts.browse().then(function (page) {
ghost.doFilter('prePostsRender', page.posts, function (posts) {
res.render('index', {posts: posts});
2013-05-11 11:44:25 -05:00
});
});
},
'single': function (req, res) {
api.posts.read({'slug': req.params.slug}).then(function (post) {
ghost.doFilter('prePostsRender', post.toJSON(), function (post) {
res.render('single', {post: post});
2013-05-11 11:44:25 -05:00
});
});
}
};
2013-05-11 11:44:25 -05:00
module.exports = frontendControllers;