0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/server/lib/mobiledoc/converters/index.js
Nazar Gargol f394eaa7b8 Added optional support for HTML source
closes TryGhost/Ghost-SDK/issues/51

- Due to JSDOM not supporting Node v6 the support for HTML conversion is now optional
2019-02-21 13:27:47 +07:00

40 lines
1.5 KiB
JavaScript

const common = require('../../common');
module.exports = {
get mobiledocConverter() {
return require('./mobiledoc-converter');
},
get markdownConverter() {
return require('./markdown-converter');
},
get htmlToMobiledocConverter() {
try {
return require('@tryghost/html-to-mobiledoc').toMobiledoc;
} catch (err) {
if (process.versions.node.startsWith('v6.')) {
// NOTE: When Node v6 is dropped this code block should be removed
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 upgrade to Node.js v10',
code: 'HTML_TO_MOBILEDOC_INSTALLATION',
err: err
});
};
} else {
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
});
};
}
}
}
};