docusaurus/v2/lib/load/theme.js
Yangshun Tay 9d4a5d5359
Prettify all JavaScript files (#964)
* Prettify all JavaScript files

* Make trailingComma all

* Delete v2/.prettierignore

* Remove v2 Prettier commands in package.json
2018-09-17 15:34:55 +08:00

20 lines
599 B
JavaScript

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, '../theme');
const themeComponents = ['Docs', 'Loading', 'NotFound', 'Markdown'];
themeComponents.forEach(component => {
if (!require.resolve(path.join(themePath, component))) {
throw new Error(
`Failed to load ${themePath}/${component}. It does not exist.`,
);
}
});
return themePath;
};