mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-28 15:37:49 +02:00
feat(v2): live reload sidebars.json (#1058)
This commit is contained in:
parent
d8e5f315f1
commit
3e901f8706
2 changed files with 10 additions and 2 deletions
|
@ -2,11 +2,14 @@ const fs = require('fs-extra');
|
|||
const path = require('path');
|
||||
const {idx} = require('../utils');
|
||||
|
||||
module.exports = function loadSidebars({siteDir, env}) {
|
||||
module.exports = function loadSidebars({siteDir, env}, deleteCache = true) {
|
||||
let allSidebars = {};
|
||||
|
||||
// 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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue