Ghost/core/frontend/services/theme-engine/config/index.js
Hannah Wolfe fdf38ba8c6
Initial card asset service implementation
- Requires the new @tryghost/minifier package
- Adds a new service that will handle taking config from the theme and optionally including assets for Koenig editor cards
- It supports both css and js as cards may need one or both
- For any given config, the tool can find the matching files to include and concat and minify them into one file per type
- Currently has an override in place so that this is not yet customisable in the theme - will remove this override when we're ready for the feature
2021-11-04 11:34:40 +00:00

18 lines
629 B
JavaScript

const _ = require('lodash');
const defaultConfig = require('./defaults');
const allowedKeys = ['posts_per_page', 'image_sizes', 'card_assets'];
module.exports.create = function configLoader(packageJson) {
let config = _.cloneDeep(defaultConfig);
if (packageJson && Object.prototype.hasOwnProperty.call(packageJson, 'config')) {
config = _.assign(config, _.pick(packageJson.config, allowedKeys));
}
// @TOD0: remove this guard when we're ready
// Temporary override to prevent themes from controlling this until we're ready
config.card_assets = defaultConfig.card_assets;
return config;
};