Speech as a package #416

Merged
bones7242 merged 89 commits from speech-as-a-package into master 2018-04-18 21:47:34 +02:00
6 changed files with 14 additions and 15 deletions
Showing only changes of commit 4d7e4a5ce0 - Show all commits

View file

@ -1,4 +1,4 @@
const { componentsConfig } = require('../../config/siteConfig.js');
const { customComponents } = require('../../config/siteConfig.js');
function getDeepestChildValue (parent, childrenKeys) {
let childKey = childrenKeys.shift(); // .shift() retrieves the first element of array and removes it from array
@ -19,17 +19,16 @@ export const dynamicImport = (filePath) => {
console.log('dynamicImport > filePath type:', typeof filePath);
throw new Error('file path provided to dynamicImport() must be a string');
}
if (!componentsConfig) {
console.log('no componentsConfig found in siteConfig.js');
if (!customComponents) {
return require(`${filePath}`);
}
// split out the file folders // filter out any empty or white-space-only strings
const folders = filePath.split('/').filter(folderName => folderName.replace(/\s/g, '').length);
// check for the component corresponding to file path in the site config object
// i.e. componentsConfig[folders[0]][folders[2][...][folders[n]]
const customComponent = getDeepestChildValue(componentsConfig, folders);
if (customComponent) {
return customComponent; // return custom component
// i.e. customComponents[folders[0]][folders[2][...][folders[n]]
const component = getDeepestChildValue(customComponents, folders);
if (component) {
return component; // return custom component
} else {
return require(`${filePath}`);
}

View file

@ -10,7 +10,7 @@ function SiteConfig () {
this.auth = {
sessionKey: 'default',
};
this.componentsConfig = {
this.customComponents = {
components: {},
containers: {},
pages : {},
@ -35,13 +35,13 @@ function SiteConfig () {
if (!config) {
return console.log('No site config received.');
}
const { analytics, assetDefaults, auth, componentsConfig, details, publishing } = config;
const { analytics, assetDefaults, auth, customComponents, details, publishing } = config;
this.analytics = analytics;
this.assetDefaults = assetDefaults;
this.auth = auth;
this.details = details;
this.publishing = publishing;
this.componentsConfig = componentsConfig;
this.customComponents = customComponents;
};
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long