Config Variables and Functions
Since Maizzle is fully configured in JavaScript, you can programatically set config options and make data available to your Templates.
Variables
Here's a very basic example of using variables in config options:
// config.js
// Define additional paths for PurgeCSS to scan
let extraPurgePaths = [
'./src/2019/clients/**/*.*',
'../up/a/level/**/*.*'
]
module.exports = {
purgeCSS: {
content: [
'src/layouts/**/*.*',
'src/partials/**/*.*',
'src/components/**/*.*',
...extraPurgePaths, // spread the array variable
],
// ...
},
}
Functions
When using a function, you need to make sure that:
- it returns something
- you invoke it
// config.js
const foo = function() {
return 'manchu'
}
module.exports = {
foo: foo(), // invoke function defined above
bar: function() {
// do stuff and return
}(), // invoke function
}
The dynamic titles example uses a self-invoking function.