docusaurus/v2/lib/load/theme.js
Endilie Yacop Sucipto 12fd204840
feat(v2): implement blog (#1062)
* feat(v2): implement blog

* expect flat blog structure

* \n

* blogpage can import many posts
2018-10-25 14:23:29 +08:00

28 lines
664 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 = [
'Doc',
'BlogPost',
'BlogPage',
'Pages',
'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;
};