lib/loaders/utils/processComponent.js
/**
 * Return an object with all required for style guide information for a given component.
 *
 * @param {string} filepath
 * @param {object} config
 * @returns {object}
 */
Return an object with all required for style guide information for a given component.
@param {string} filepath
@param {object} config
@returns {object}
Return an object with all required for style guide information for a given component . @param { string } filepath @param { object } config @returns { object }
function processComponent(filepath, config) {
  const componentPath = _path.default.relative(config.configDir, filepath);
  const componentName = (0, _getNameFromFilePath.default)(filepath);
  const examplesFile = config.getExampleFilename(filepath);
  const componentMetadataPath = getComponentMetadataPath(filepath);
  return {
    filepath: componentPath,
    slug: _slugger.default.slug(componentName),
    pathLine: config.getComponentPathLine(componentPath),
    module: (0, _requireIt.default)(filepath),
    props: (0, _requireIt.default)(`!!${propsLoader}!${filepath}`),
    hasExamples: !!(examplesFile && _fs.default.existsSync(examplesFile)),
    metadata: _fs.default.existsSync(componentMetadataPath) ? (0, _requireIt.default)(componentMetadataPath) : {}
  };
}
function processComponent ( filepath , config ) { const componentPath = _path . default . relative ( config . configDir , filepath ) ; const componentName = ( 0 , _getNameFromFilePath . default ) ( filepath ) ; const examplesFile = config . getExampleFilename ( filepath ) ; const componentMetadataPath = getComponentMetadataPath ( filepath ) ; return { filepath : componentPath , slug : _slugger . default . slug ( componentName ) , pathLine : config . getComponentPathLine ( componentPath ) , module : ( 0 , _requireIt . default ) ( filepath ) , props : ( 0 , _requireIt . default ) ( ` ${ propsLoader } ${ filepath } ` ) , hasExamples : ! ! ( examplesFile && _fs . default . existsSync ( examplesFile ) ) , metadata : _fs . default . existsSync ( componentMetadataPath ) ? ( 0 , _requireIt . default ) ( componentMetadataPath ) : { } } ; }
Return an object with all required for style guide information for a given component.
Return an object with all required for style guide information for a given component .