mirror of
https://github.com/jgthms/bulma
synced 2026-03-15 10:14:29 -07:00
Init variables script
This commit is contained in:
3
docs/scripts/.gitignore
vendored
Normal file
3
docs/scripts/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Folders
|
||||
|
||||
/output
|
||||
25
docs/scripts/read-sass-variables.js
Normal file
25
docs/scripts/read-sass-variables.js
Normal file
@@ -0,0 +1,25 @@
|
||||
module.exports = plugin;
|
||||
|
||||
function plugin() {
|
||||
return (files, metalsmith, done) => {
|
||||
setImmediate(done);
|
||||
|
||||
Object.keys(files).forEach(file_path => {
|
||||
const file = files[file_path];
|
||||
const lines = file.contents.toString().split(/(?:\r\n|\r|\n)/g);
|
||||
|
||||
lines.forEach(line => {
|
||||
if (line.startsWith('$') && line.endsWith('!default')) {
|
||||
const colon_index = line.indexOf(':');
|
||||
const variable_name = line.substring(0, colon_index).trim();
|
||||
|
||||
const default_index = line.indexOf('!default');
|
||||
const variable_value = line.substring(colon_index + 1, default_index).trim();
|
||||
|
||||
console.log('variable_name', variable_name);
|
||||
console.log('variable_value', variable_value);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
18
docs/scripts/variables.js
Normal file
18
docs/scripts/variables.js
Normal file
@@ -0,0 +1,18 @@
|
||||
var Metalsmith = require('metalsmith');
|
||||
var filter = require('metalsmith-filter');
|
||||
var writemetadata = require('metalsmith-writemetadata');
|
||||
|
||||
var regex = '**/*-variables.sass';
|
||||
// var regex = '**/*.sass';
|
||||
var plugin = require('./read-sass-variables');
|
||||
|
||||
Metalsmith(__dirname)
|
||||
.source('../../sass')
|
||||
.destination('./output')
|
||||
.clean(true)
|
||||
.use(filter(regex))
|
||||
.use(plugin())
|
||||
.use(writemetadata())
|
||||
.build(function(err) {
|
||||
if (err) throw err;
|
||||
});
|
||||
Reference in New Issue
Block a user