mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
34 lines
No EOL
1.1 KiB
JavaScript
34 lines
No EOL
1.1 KiB
JavaScript
/**
|
|
* Main controller for Ghost frontend
|
|
*/
|
|
|
|
/*global require, module */
|
|
(function () {
|
|
'use strict';
|
|
|
|
var Ghost = require('../../ghost'),
|
|
api = require('../../shared/api'),
|
|
|
|
ghost = new Ghost(),
|
|
frontendControllers;
|
|
|
|
frontendControllers = {
|
|
'homepage': function (req, res) {
|
|
api.posts.browse().then(function (posts) {
|
|
ghost.doFilter('prePostsRender', posts.toJSON(), function (posts) {
|
|
res.render('index', {posts: posts, ghostGlobals: res.locals.ghostGlobals, navItems: res.locals.navItems});
|
|
});
|
|
|
|
});
|
|
},
|
|
'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, ghostGlobals: res.locals.ghostGlobals, navItems: res.locals.navItems});
|
|
});
|
|
});
|
|
}
|
|
};
|
|
|
|
module.exports = frontendControllers;
|
|
}()); |