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

View file

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