src/index.js
async function(filePath, index, resolvers, opts) {

	// Use the filePath to generate a unique id
	const id = crypto.createHash('sha1').update(filePath).digest('hex')

	// File name and extension
	const { name: fileName, ext: fileExt } = path.parse(filePath)

	// Absolute directory path to the component
	const fileCwd = path.resolve(opts.cwd, path.dirname(filePath))

	// Absolute preview URL
	const rawURL = '/' + rename(filePath, '.html')
	const processedURL = opts.url(rawURL)

	// Reuse data from resolver and add additional information
	const data = await pMap(resolvers, async (resolver, index) => {

		return Object.assign({}, resolver, {
			index,
			data: await getFile(fileName, fileExt, resolver.resolve, resolver.parse, fileCwd)
		})

	})

	return {
		index,
		id,
		name: fileName,
		src: filePath,
		url: processedURL,
		data
	}

}
async function(filePath, index, resolvers, opts) {

	// Use the filePath to generate a unique id
	const id = crypto.createHash('sha1').update(filePath).digest('hex')

	// File name and extension
	const { name: fileName, ext: fileExt } = path.parse(filePath)

	// Absolute directory path to the component
	const fileCwd = path.resolve(opts.cwd, path.dirname(filePath))

	// Absolute preview URL
	const rawURL = '/' + rename(filePath, '.html')
	const processedURL = opts.url(rawURL)

	// Reuse data from resolver and add additional information
	const data = await pMap(resolvers, async (resolver, index) => {

		return Object.assign({}, resolver, {
			index,
			data: await getFile(fileName, fileExt, resolver.resolve, resolver.parse, fileCwd)
		})

	})

	return {
		index,
		id,
		name: fileName,
		src: filePath,
		url: processedURL,
		data
	}

}
async function ( filePath , index , resolvers , opts ) { // Use the filePath to generate a unique id const id = crypto . createHash ( 'sha1' ) . update ( filePath ) . digest ( 'hex' ) // File name and extension const { name : fileName , ext : fileExt } = path . parse ( filePath ) // Absolute directory path to the component const fileCwd = path . resolve ( opts . cwd , path . dirname ( filePath ) ) // Absolute preview URL const rawURL = '/' + rename ( filePath , '.html' ) const processedURL = opts . url ( rawURL ) // Reuse data from resolver and add additional information const data = await pMap ( resolvers , async ( resolver , index ) => { return Object . assign ( { } , resolver , { index , data : await getFile ( fileName , fileExt , resolver . resolve , resolver . parse , fileCwd ) } ) } ) return { index , id , name : fileName , src : filePath , url : processedURL , data } }
Gather information about a component.
@public
@param {String} filePath - Relative path to component.
@param {Number} index - Index of the current element being processed.
@param {Array} resolvers - Array of objects with functions that return an array of paths to tell the potential location of files.
@param {Object} opts - Options.
@returns {Promise<Object>} Information of a component.
Gather information about a component .