mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
06b03bbcfe
no issue - Split out 'getPostPage' & rename to fetchData - Split format response methods into own files - Split out handleError - Split out setReqCtx and rename to setRequestIsSecure - Split out theme paths - Refactor tests in index_spec.js to be more robust - Add tests to bring coverage for split file up to 100%
31 lines
706 B
JavaScript
31 lines
706 B
JavaScript
var _ = require('lodash');
|
|
|
|
/**
|
|
* formats variables for handlebars in multi-post contexts.
|
|
* If extraValues are available, they are merged in the final value
|
|
* @return {Object} containing page variables
|
|
*/
|
|
function formatPageResponse(posts, page, extraValues) {
|
|
extraValues = extraValues || {};
|
|
|
|
var resp = {
|
|
posts: posts,
|
|
pagination: page.meta.pagination
|
|
};
|
|
return _.extend(resp, extraValues);
|
|
}
|
|
|
|
/**
|
|
* similar to formatPageResponse, but for single post pages
|
|
* @return {Object} containing page variables
|
|
*/
|
|
function formatResponse(post) {
|
|
return {
|
|
post: post
|
|
};
|
|
}
|
|
|
|
module.exports = {
|
|
channel: formatPageResponse,
|
|
single: formatResponse
|
|
};
|