feat: add siteConfig loader

This commit is contained in:
endiliey 2018-07-28 16:06:07 +08:00
parent 06faff3474
commit 94c45e36cb
11 changed files with 4726 additions and 51 deletions

14
lib/loader/config.js Normal file
View file

@ -0,0 +1,14 @@
const fs = require('fs-extra');
const path = require('path');
module.exports = function loadConfig(sourceDir, deleteCache = true) {
const configPath = path.resolve(sourceDir, '.blogi', 'config.js');
if (deleteCache) {
delete require.cache[configPath];
}
let config = {};
if (fs.existsSync(configPath)) {
config = require(configPath);
}
return config;
};