mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
Enabled collections rendering (#18150)
refs TryGhost/Product#3883 - passes endpoint through to the lexical renderer for collections rendering - ghost still needs a `kg-default-nodes` and `kg-lexical-html-renderer` update to support this completely
This commit is contained in:
parent
384c232b1a
commit
488af56ef9
@ -3,6 +3,8 @@ const errors = require('@tryghost/errors');
|
||||
const urlUtils = require('../../shared/url-utils');
|
||||
const config = require('../../shared/config');
|
||||
const storage = require('../adapters/storage');
|
||||
const getPostServiceInstance = require('../services/posts/posts-service');
|
||||
const postsService = getPostServiceInstance();
|
||||
|
||||
let nodes;
|
||||
let lexicalHtmlRenderer;
|
||||
@ -28,6 +30,13 @@ module.exports = {
|
||||
},
|
||||
|
||||
async render(lexical, userOptions = {}) {
|
||||
const getCollectionPosts = async (collectionSlug, postCount) => {
|
||||
const transacting = userOptions.transacting;
|
||||
const {data} = await postsService.browsePosts({collection: collectionSlug, limit: postCount, transacting});
|
||||
let posts = data.map(p => p.toJSON());
|
||||
return posts;
|
||||
};
|
||||
|
||||
const options = Object.assign({
|
||||
siteUrl: config.get('url'),
|
||||
imageOptimization: config.get('imageOptimization'),
|
||||
@ -43,7 +52,8 @@ module.exports = {
|
||||
createDocument() {
|
||||
const {JSDOM} = require('jsdom');
|
||||
return (new JSDOM()).window.document;
|
||||
}
|
||||
},
|
||||
getCollectionPosts
|
||||
}, userOptions);
|
||||
|
||||
return await this.lexicalHtmlRenderer.render(lexical, options);
|
||||
@ -94,4 +104,4 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue
Block a user