Added serialization to collection posts fetch (#18179)

no refs
- renderer was missing data from serializer
This commit is contained in:
Steve Larson 2023-09-15 10:33:36 -05:00 committed by GitHub
parent 3a8fac8348
commit 077bd2c883
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ const errors = require('@tryghost/errors');
const urlUtils = require('../../shared/url-utils');
const config = require('../../shared/config');
const storage = require('../adapters/storage');
const serializePosts = require('../api/endpoints/utils/serializers/output/posts').all;
let nodes;
let lexicalHtmlRenderer;
@ -35,15 +36,30 @@ module.exports = {
}
const getCollectionPosts = async (collectionSlug, postCount) => {
const frame = {
options: {
columns: ['url','excerpt']
},
original: {
context: {
member: {
status: 'paid'
}
}
},
apiType: 'content',
response: {}
};
const transacting = userOptions.transacting;
const {data} = await postsService.browsePosts({
const response = await postsService.browsePosts({
context: {public: true}, // mimic Content API request
collection: collectionSlug,
limit: postCount,
transacting
});
let posts = data.map(p => p.toJSON());
return posts;
await serializePosts(response, null, frame);
return frame.response.posts;
};
const options = Object.assign({