Ghost/core/server/controllers/frontend/channel-config.js
Hannah Wolfe 050f1751c4 Simplify config for channels (#9158)
refs #5091

- remove the use of functions
- remove unnecessary quotes from tag filter
- move channel config to be a JSOn file called config.channels.json
- accept external config
- new channelUtils for tests
- remove channelConfig.get 
- refactor so tests work as expected
- refactor away duplicate 'name' value
2017-10-24 17:18:35 +01:00

28 lines
837 B
JavaScript

var _ = require('lodash'),
channels = [];
function loadConfig() {
var channelConfig = {};
// This is a very dirty temporary hack so that we can test out channels with some Beta testers
// If you are reading this code, and considering using it, best reach out to us on Slack
// Definitely don't be angry at us if the structure of the JSON changes or this goes away.
try {
channelConfig = require('../../../../config.channels.json');
} catch (err) {
channelConfig = require('./config.channels.json');
}
return channelConfig;
}
module.exports.list = function list() {
_.each(loadConfig(), function (channelConfig, channelName) {
var channel = _.cloneDeep(channelConfig);
channel.name = channelName;
channels.push(channel);
});
return channels;
};