2020-03-19 12:18:54 +00:00
|
|
|
const common = require('../common');
|
2020-03-25 19:53:11 +00:00
|
|
|
const config = require('../../config');
|
|
|
|
|
|
|
|
let cardFactory, cards;
|
2017-12-14 12:09:54 +01:00
|
|
|
|
2020-03-19 12:18:54 +00:00
|
|
|
module.exports = {
|
2017-12-14 12:09:54 +01:00
|
|
|
get cards() {
|
2020-03-25 19:53:11 +00:00
|
|
|
if (cards) {
|
|
|
|
return cards;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CardFactory = require('@tryghost/kg-card-factory');
|
|
|
|
const defaultCards = require('@tryghost/kg-default-cards');
|
|
|
|
|
|
|
|
cardFactory = new CardFactory({
|
|
|
|
siteUrl: config.get('url')
|
|
|
|
});
|
|
|
|
|
|
|
|
cards = defaultCards.map((card) => {
|
|
|
|
return cardFactory.createCard(card);
|
|
|
|
});
|
|
|
|
|
|
|
|
return cards;
|
2017-12-14 12:09:54 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
get atoms() {
|
|
|
|
return require('./atoms');
|
|
|
|
},
|
|
|
|
|
2020-03-18 14:39:49 +00:00
|
|
|
get renderers() {
|
|
|
|
return require('./renderers');
|
2020-03-19 12:18:54 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
get htmlToMobiledocConverter() {
|
|
|
|
try {
|
|
|
|
return require('@tryghost/html-to-mobiledoc').toMobiledoc;
|
|
|
|
} catch (err) {
|
|
|
|
return () => {
|
|
|
|
throw new common.errors.InternalServerError({
|
|
|
|
message: 'Unable to convert from source HTML to Mobiledoc',
|
|
|
|
context: 'The html-to-mobiledoc package was not installed',
|
|
|
|
help: 'Please review any errors from the install process by checking the Ghost logs',
|
|
|
|
code: 'HTML_TO_MOBILEDOC_INSTALLATION',
|
|
|
|
err: err
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
2017-03-15 07:07:33 +13:00
|
|
|
}
|
|
|
|
};
|