docusaurus/packages/docusaurus/lib/server/load/theme.js
Endilie Yacop Sucipto 15bc33df50
chore(v2): rename/ restructure folder (#1351)
* chore(v2): restructure folder

* typo

* fix test
2019-04-10 14:20:15 +07:00

37 lines
865 B
JavaScript

/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const fs = require('fs-extra');
const path = require('path');
module.exports = function loadConfig(siteDir) {
const customThemePath = path.resolve(siteDir, 'theme');
const themePath = fs.existsSync(customThemePath)
? customThemePath
: path.resolve(__dirname, '../../default-theme');
const themeComponents = [
'Doc',
'Pages',
'Loading',
'NotFound',
'Markdown',
'Search',
];
themeComponents.forEach(component => {
try {
require.resolve(path.join(themePath, component));
} catch (e) {
throw new Error(
`Failed to load ${themePath}/${component}. It does not exist.`,
);
}
});
return themePath;
};