mirror of
https://github.com/jgthms/bulma
synced 2026-03-19 20:04:30 -07:00
Rename scripts folder
This commit is contained in:
40
docs/_scripts/plugins/02-read-derived-variables.js
Normal file
40
docs/_scripts/plugins/02-read-derived-variables.js
Normal file
@@ -0,0 +1,40 @@
|
||||
module.exports = plugin;
|
||||
|
||||
const utils = require('./utils');
|
||||
const fs = require('fs');
|
||||
|
||||
let initial_variables = JSON.parse(fs.readFileSync(utils.files.initial_variables));
|
||||
let derived_variables = JSON.parse(fs.readFileSync(utils.files.derived_variables));
|
||||
|
||||
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) {
|
||||
const computed_data = utils.getComputedData(variable.name, variable.value, variable.type, initial_variables, derived_variables);
|
||||
|
||||
if (Object.keys(computed_data).length > 0) {
|
||||
variable.computed_type = computed_data.computed_type;
|
||||
variable.computed_value = computed_data.computed_value;
|
||||
}
|
||||
|
||||
variables.by_name[variable.name] = variable;
|
||||
variables.list.push(variable.name);
|
||||
}
|
||||
});
|
||||
|
||||
utils.writeFile(file_path, variables);
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user