mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-25 06:56:56 +02:00
feat: add siteConfig loader
This commit is contained in:
parent
06faff3474
commit
94c45e36cb
11 changed files with 4726 additions and 51 deletions
0
lib/loader/blog.js
Normal file
0
lib/loader/blog.js
Normal file
14
lib/loader/config.js
Normal file
14
lib/loader/config.js
Normal 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;
|
||||
};
|
12
lib/loader/index.js
Normal file
12
lib/loader/index.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
const path = require('path');
|
||||
const loadConfig = require('./config');
|
||||
|
||||
module.exports = async function load(sourceDir) {
|
||||
// 1. load siteConfig
|
||||
const siteConfig = loadConfig(sourceDir);
|
||||
|
||||
// 2. extract metadata from markdown files
|
||||
const metadatas = [];
|
||||
|
||||
return null; // todo
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue