mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-28 05:58:38 +02:00
refactor: rename loader to load as not to confuse webpack loader
This commit is contained in:
parent
36eee2941a
commit
9fef99cb18
15 changed files with 4 additions and 131 deletions
58
lib/load/index.js
Normal file
58
lib/load/index.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const loadConfig = require('./config');
|
||||
const loadBlog = require('./blog');
|
||||
const loadDocs = require('./docs');
|
||||
const {generate} = require('../helpers');
|
||||
|
||||
module.exports = async function load(siteDir) {
|
||||
// load siteConfig
|
||||
const siteConfig = loadConfig(siteDir);
|
||||
|
||||
// docs
|
||||
const docsRelativeDir = siteConfig.customDocsPath || 'docs';
|
||||
const docsMetadata = await loadDocs(
|
||||
path.resolve(siteDir, '..', docsRelativeDir)
|
||||
);
|
||||
await generate(
|
||||
'docsMetadata.js',
|
||||
`${'/**\n * @generated\n */\n' + 'module.exports = '}${JSON.stringify(
|
||||
docsMetadata,
|
||||
null,
|
||||
2
|
||||
)};\n`
|
||||
);
|
||||
|
||||
// blog
|
||||
const blogMetadata = await loadBlog(path.resolve(siteDir, 'blog'));
|
||||
await generate(
|
||||
'blogMetadata.js',
|
||||
`${'/**\n * @generated\n */\n' + 'module.exports = '}${JSON.stringify(
|
||||
blogMetadata,
|
||||
null,
|
||||
2
|
||||
)};\n`
|
||||
);
|
||||
|
||||
// resolve outDir
|
||||
const outDir = siteConfig.dest
|
||||
? path.resolve(siteConfig.dest)
|
||||
: path.resolve(siteDir, '.munseo/dist');
|
||||
|
||||
// resolve the path of our app user interface layout
|
||||
const uiPath =
|
||||
!siteConfig.uiPath ||
|
||||
!fs.existsSync(path.resolve(siteDir, siteConfig.uiPath))
|
||||
? path.resolve(__dirname, '../ui')
|
||||
: siteConfig.uiPath;
|
||||
|
||||
const baseUrl = siteConfig.baseUrl || '/';
|
||||
|
||||
return {
|
||||
siteConfig,
|
||||
siteDir,
|
||||
outDir,
|
||||
uiPath,
|
||||
baseUrl
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue