2017-11-08 13:00:25 +03:00
|
|
|
var debug = require('ghost-ignition').debug('channels:render-post'),
|
|
|
|
formatResponse = require('./format-response'),
|
2017-11-10 15:44:29 +03:00
|
|
|
renderer = require('./renderer');
|
2017-11-08 13:00:25 +03:00
|
|
|
/*
|
|
|
|
* Sets the response context around an entry (post or page)
|
|
|
|
* and renders it with the correct template.
|
|
|
|
* Used by post preview and entry methods.
|
|
|
|
* Returns a function that takes the entry to be rendered.
|
|
|
|
*/
|
|
|
|
module.exports = function renderEntry(req, res) {
|
|
|
|
debug('renderEntry called');
|
|
|
|
return function renderEntry(entry) {
|
|
|
|
// Renderer begin
|
|
|
|
// Format data 2 - 1 is in preview/entry
|
2017-11-10 15:44:29 +03:00
|
|
|
var data = formatResponse.entry(entry);
|
2017-11-08 13:00:25 +03:00
|
|
|
|
|
|
|
// Render Call
|
2017-11-10 15:44:29 +03:00
|
|
|
return renderer(req, res, data);
|
2017-11-08 13:00:25 +03:00
|
|
|
};
|
|
|
|
};
|