docusaurus/packages/docusaurus/lib/server/load/theme.js
Endi 373d17ee72
refactor(v2): simplify code by removing wip i18n & translation (#1431)
* refactor(v2): remove i18n & versioning + cleaner code

* totally remove i18n and versioning from plugin
2019-05-02 17:24:47 +07:00

31 lines
804 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 requiredComponents = ['Loading', 'NotFound'];
requiredComponents.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;
};