0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Cleaned up AMP rendering of "page" resources

refs https://github.com/TryGhost/Toolbox/issues/332

- After dropping support for `page: (true|false)` for post resources in Content API there is no need to check for `body.post.page` in the AMP renderer. Furthermore, the AMP router uses `public-post` controller that **only** returns "post" resources. This check was a redundant, unnecessary piece of logic
This commit is contained in:
Naz 2022-05-17 11:39:43 +08:00
parent d8e9cbf9db
commit 5abd67809d
2 changed files with 2 additions and 17 deletions

View file

@ -26,8 +26,7 @@ function _renderer(req, res, next) {
// Format data
let body = req.body || {};
// CASE: we only support amp pages for posts that are not static pages
if (!body.post || body.post.page) {
if (!body.post) {
return next(new errors.NotFoundError({message: tpl(messages.pageNotFound)}));
}
@ -70,7 +69,7 @@ function getPostData(req, res, next) {
}));
}
// @NOTE: amp is not supported for static pages
// @NOTE: amp is not supported for "page" resource
// @TODO: https://github.com/TryGhost/Ghost/issues/10548
dataService.entryLookup(urlWithoutSubdirectoryWithoutAmp, {permalinks, query: {controller: 'postsPublic', resource: 'posts'}}, res.locals)
.then((result) => {

View file

@ -77,20 +77,6 @@ describe('Unit - apps/amp/lib/router', function () {
done();
});
});
it('throws 404 when req.body.post is a page', function (done) {
req.body = {
post: {
page: true
}
};
ampController.renderer(req, res, function (err) {
(err instanceof errors.NotFoundError).should.be.true();
renderer.renderer.called.should.be.false();
done();
});
});
});
describe('fn: getPostData', function () {