🐛 Allowed data in collections to use specified key (#10559)
closes #10434 This adds the list of objects to the specified key, finishing off the work started in the PR here: https://github.com/TryGhost/Ghost/pull/10449
This commit is contained in:
parent
f846bd8033
commit
98b4940f70
@ -105,10 +105,12 @@ function fetchData(pathOptions, routerOptions, locals) {
|
||||
response.data = {};
|
||||
|
||||
_.each(routerOptions.data, function (config, name) {
|
||||
response.data[name] = results[name][config.resource];
|
||||
|
||||
if (config.type === 'browse') {
|
||||
response.data[name] = results[name];
|
||||
} else {
|
||||
response.data[name] = results[name][config.resource];
|
||||
response.data[name].meta = results[name].meta;
|
||||
// @TODO remove in v3
|
||||
response.data[name][config.resource] = results[name][config.resource];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -98,6 +98,8 @@ describe('Unit - services/routing/helpers/fetch-data', function () {
|
||||
result.data.featured.should.not.have.properties('data');
|
||||
|
||||
result.posts.length.should.eql(posts.length);
|
||||
result.data.featured.length.should.eql(posts.length);
|
||||
// @TODO v3 will deprecate this style (featured.posts)
|
||||
result.data.featured.posts.length.should.eql(posts.length);
|
||||
|
||||
api.posts.browse.calledTwice.should.be.true();
|
||||
@ -133,6 +135,8 @@ describe('Unit - services/routing/helpers/fetch-data', function () {
|
||||
result.data.featured.should.not.have.properties('data');
|
||||
|
||||
result.posts.length.should.eql(posts.length);
|
||||
result.data.featured.length.should.eql(posts.length);
|
||||
// @TODO v3 will deprecate this style (featured.posts)
|
||||
result.data.featured.posts.length.should.eql(posts.length);
|
||||
|
||||
api.posts.browse.calledTwice.should.be.true();
|
||||
|
Loading…
Reference in New Issue
Block a user