changed custom component config name and rebuilt

This commit is contained in:
bill bittner 2018-03-22 12:45:03 -07:00
parent c2c95ddc8a
commit 4d7e4a5ce0
6 changed files with 14 additions and 15 deletions

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