We can load the _config.yml as a json object in the gruntfile with js-yaml and the following code:
grunt = require('grunt');
var jekyllConfig = require("js-yaml").safeLoad(grunt.file.read('_config.yml'));
console.log(jekyllConfig); // Prints _config.yml, jsonified
I initially wanted this to load the value of keep_files into an exclude list in the Grunt clean task, but there are a couple of shortcomings to this approach:
Only reads the actual values in the _config.yml. Doesn't know anything about Jekyll defaults.
Doesn't know about multiple configuration files listed in the Grunt task.
Doesn't know about config files added programmatically in plugins like Jekyll Picture Tag.
Not sure if there's a benefit > work + complexity solution to this.
We can load the _config.yml as a json object in the gruntfile with js-yaml and the following code:
I initially wanted this to load the value of
keep_files
into an exclude list in the Grunt clean task, but there are a couple of shortcomings to this approach:Not sure if there's a benefit > work + complexity solution to this.