mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Added serialization to collection posts fetch (#18179)
no refs - renderer was missing data from serializer
This commit is contained in:
parent
3a8fac8348
commit
077bd2c883
1 changed files with 19 additions and 3 deletions
|
@ -3,6 +3,7 @@ const errors = require('@tryghost/errors');
|
||||||
const urlUtils = require('../../shared/url-utils');
|
const urlUtils = require('../../shared/url-utils');
|
||||||
const config = require('../../shared/config');
|
const config = require('../../shared/config');
|
||||||
const storage = require('../adapters/storage');
|
const storage = require('../adapters/storage');
|
||||||
|
const serializePosts = require('../api/endpoints/utils/serializers/output/posts').all;
|
||||||
|
|
||||||
let nodes;
|
let nodes;
|
||||||
let lexicalHtmlRenderer;
|
let lexicalHtmlRenderer;
|
||||||
|
@ -35,15 +36,30 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCollectionPosts = async (collectionSlug, postCount) => {
|
const getCollectionPosts = async (collectionSlug, postCount) => {
|
||||||
|
const frame = {
|
||||||
|
options: {
|
||||||
|
columns: ['url','excerpt']
|
||||||
|
},
|
||||||
|
original: {
|
||||||
|
context: {
|
||||||
|
member: {
|
||||||
|
status: 'paid'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
apiType: 'content',
|
||||||
|
response: {}
|
||||||
|
};
|
||||||
|
|
||||||
const transacting = userOptions.transacting;
|
const transacting = userOptions.transacting;
|
||||||
const {data} = await postsService.browsePosts({
|
const response = await postsService.browsePosts({
|
||||||
context: {public: true}, // mimic Content API request
|
context: {public: true}, // mimic Content API request
|
||||||
collection: collectionSlug,
|
collection: collectionSlug,
|
||||||
limit: postCount,
|
limit: postCount,
|
||||||
transacting
|
transacting
|
||||||
});
|
});
|
||||||
let posts = data.map(p => p.toJSON());
|
await serializePosts(response, null, frame);
|
||||||
return posts;
|
return frame.response.posts;
|
||||||
};
|
};
|
||||||
|
|
||||||
const options = Object.assign({
|
const options = Object.assign({
|
||||||
|
|
Loading…
Add table
Reference in a new issue