refactor(v2): load sidebars from docs plugin (#1328)

* refactor(v2): load sidebars from docs plugin

* fix(v2): update tests

* fix(v2): change to sidebarPath
This commit is contained in:
Yangshun Tay 2019-04-01 19:42:14 -07:00 committed by GitHub
parent 8dd6bc1082
commit 029aa636a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 71 additions and 42 deletions

View file

@ -113,19 +113,10 @@ function normalizeSidebar(sidebars) {
}, {});
}
module.exports = function loadSidebars({siteDir, env}, deleteCache = true) {
let allSidebars = {};
module.exports = function loadSidebars({siteDir, env, sidebar}) {
const allSidebars = sidebar;
// current sidebars
const sidebarsJSONFile = path.join(siteDir, 'sidebars.json');
if (deleteCache) {
delete require.cache[sidebarsJSONFile];
}
if (fs.existsSync(sidebarsJSONFile)) {
allSidebars = require(sidebarsJSONFile); // eslint-disable-line
}
// versioned sidebars
// Versioned sidebars.
if (idx(env, ['versioning', 'enabled'])) {
const versions = idx(env, ['versioning', 'versions']);
if (Array.isArray(versions)) {