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:
parent
d8e9cbf9db
commit
5abd67809d
2 changed files with 2 additions and 17 deletions
|
@ -26,8 +26,7 @@ function _renderer(req, res, next) {
|
||||||
// Format data
|
// Format data
|
||||||
let body = req.body || {};
|
let body = req.body || {};
|
||||||
|
|
||||||
// CASE: we only support amp pages for posts that are not static pages
|
if (!body.post) {
|
||||||
if (!body.post || body.post.page) {
|
|
||||||
return next(new errors.NotFoundError({message: tpl(messages.pageNotFound)}));
|
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
|
// @TODO: https://github.com/TryGhost/Ghost/issues/10548
|
||||||
dataService.entryLookup(urlWithoutSubdirectoryWithoutAmp, {permalinks, query: {controller: 'postsPublic', resource: 'posts'}}, res.locals)
|
dataService.entryLookup(urlWithoutSubdirectoryWithoutAmp, {permalinks, query: {controller: 'postsPublic', resource: 'posts'}}, res.locals)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
|
|
@ -77,20 +77,6 @@ describe('Unit - apps/amp/lib/router', function () {
|
||||||
done();
|
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 () {
|
describe('fn: getPostData', function () {
|
||||||
|
|
Loading…
Reference in a new issue