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 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 getPostServiceInstance = require('../services/posts/posts-service');
|
||||||
|
const postsService = getPostServiceInstance();
|
||||||
|
|
||||||
let nodes;
|
let nodes;
|
||||||
let lexicalHtmlRenderer;
|
let lexicalHtmlRenderer;
|
||||||
@ -28,6 +30,13 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async render(lexical, userOptions = {}) {
|
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({
|
const options = Object.assign({
|
||||||
siteUrl: config.get('url'),
|
siteUrl: config.get('url'),
|
||||||
imageOptimization: config.get('imageOptimization'),
|
imageOptimization: config.get('imageOptimization'),
|
||||||
@ -43,7 +52,8 @@ module.exports = {
|
|||||||
createDocument() {
|
createDocument() {
|
||||||
const {JSDOM} = require('jsdom');
|
const {JSDOM} = require('jsdom');
|
||||||
return (new JSDOM()).window.document;
|
return (new JSDOM()).window.document;
|
||||||
}
|
},
|
||||||
|
getCollectionPosts
|
||||||
}, userOptions);
|
}, userOptions);
|
||||||
|
|
||||||
return await this.lexicalHtmlRenderer.render(lexical, options);
|
return await this.lexicalHtmlRenderer.render(lexical, options);
|
||||||
|
Loading…
Reference in New Issue
Block a user