diff --git a/core/frontend/services/rendering/format-response.js b/core/frontend/services/rendering/format-response.js index 48d70d5cee..98d02da0e9 100644 --- a/core/frontend/services/rendering/format-response.js +++ b/core/frontend/services/rendering/format-response.js @@ -6,7 +6,7 @@ const {prepareContextResource} = require('../proxy'); * * @return {Object} containing page variables */ -function formatPageResponse(result) { +function formatPageResponse(result, pageAsPost = false) { const response = {}; if (result.posts) { @@ -32,6 +32,10 @@ function formatPageResponse(result) { } }); + if (pageAsPost && response.page) { + response.post = response.page; + } + return response; } diff --git a/core/frontend/services/routing/controllers/static.js b/core/frontend/services/routing/controllers/static.js index 2ac32e3316..9df5a62010 100644 --- a/core/frontend/services/routing/controllers/static.js +++ b/core/frontend/services/routing/controllers/static.js @@ -60,7 +60,10 @@ module.exports = function staticController(req, res, next) { }); } - renderer.renderer(req, res, renderer.formatResponse.entries(response)); + // This flag solves the confusion about whether the output contains a post or page object by duplicating the objects + // This is not ideal, but will solve some long standing pain points with dynamic routing until we can overhaul it + const duplicatePagesAsPosts = true; + renderer.renderer(req, res, renderer.formatResponse.entries(response, duplicatePagesAsPosts)); }) .catch(renderer.handleError(next)); };