2020-03-19 15:18:54 +03:00
|
|
|
const common = require('../common');
|
2020-03-25 22:53:11 +03:00
|
|
|
const config = require('../../config');
|
|
|
|
|
|
|
|
let cardFactory, cards;
|
2017-12-14 14:09:54 +03:00
|
|
|
|
2020-03-19 15:18:54 +03:00
|
|
|
module.exports = {
|
2017-12-14 14:09:54 +03:00
|
|
|
get cards() {
|
2020-03-25 22:53:11 +03: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 14:09:54 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
get atoms() {
|
|
|
|
return require('./atoms');
|
|
|
|
},
|
|
|
|
|
2020-03-18 17:39:49 +03:00
|
|
|
get renderers() {
|
|
|
|
return require('./renderers');
|
2020-03-19 15:18:54 +03: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-14 21:07:33 +03:00
|
|
|
}
|
|
|
|
};
|