mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
feat: enable custom theme with eject
This commit is contained in:
parent
8c6bc6dd38
commit
2b5ee3e869
6 changed files with 40 additions and 7 deletions
|
@ -20,7 +20,6 @@ module.exports = function loadConfig(siteDir, deleteCache = true) {
|
|||
];
|
||||
const optionalFields = [
|
||||
'customDocsPath',
|
||||
'themePath',
|
||||
'highlight',
|
||||
'markdownPlugins'
|
||||
];
|
||||
|
|
|
@ -34,11 +34,19 @@ module.exports = async function load(siteDir) {
|
|||
const outDir = path.resolve(siteDir, 'build');
|
||||
|
||||
// resolve the theme
|
||||
const themePath =
|
||||
siteConfig.themePath &&
|
||||
fs.existsSync(path.resolve(siteDir, siteConfig.themePath))
|
||||
? siteConfig.themePath
|
||||
: path.resolve(__dirname, '../theme');
|
||||
const customThemePath = path.resolve(siteDir, 'theme');
|
||||
const themePath = fs.existsSync(customThemePath)
|
||||
? customThemePath
|
||||
: path.resolve(__dirname, '../theme');
|
||||
|
||||
const themeComponents = ['Docs', 'Loading', 'NotFound'];
|
||||
themeComponents.forEach(component => {
|
||||
if (!require.resolve(path.join(themePath, component))) {
|
||||
throw new Error(
|
||||
`Failed to load ${themePath}/${component}. It does not exist.`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const baseUrl = siteConfig.baseUrl || '/';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue