22 lines
515 B
JavaScript
22 lines
515 B
JavaScript
/** © Andy Bell - https://buildexcellentwebsit.es/ */
|
|
|
|
const slugify = require('slugify');
|
|
|
|
/**
|
|
* Converts human readable tokens into tailwind config friendly ones
|
|
*
|
|
* @param {array} tokens {name: string, value: any}
|
|
* @return {object} {key, value}
|
|
*/
|
|
const tokensToTailwind = tokens => {
|
|
const nameSlug = text => slugify(text, {lower: true});
|
|
let response = {};
|
|
|
|
tokens.forEach(({name, value}) => {
|
|
response[nameSlug(name)] = value;
|
|
});
|
|
|
|
return response;
|
|
};
|
|
|
|
module.exports = tokensToTailwind;
|