bulma/docs/_scripts/plugins/01-read-initial-variables.js
2019-05-18 16:11:16 +01:00

31 lines
646 B
JavaScript

module.exports = plugin;
const utils = require('./utils');
function plugin() {
return (files, metalsmith, done) => {
setImmediate(done);
Object.keys(files).forEach(file_path => {
const {file_name, lines} = utils.getLines(files, file_path);
let variables = {
by_name: {},
list: [],
file_path,
};
lines.forEach(line => {
const variable = utils.parseLine(line);
if (variable != false) {
variables.by_name[variable.name] = variable;
variables.list.push(variable.name);
}
});
utils.writeFile(file_path, variables);
});
};
}