mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 09:07:29 +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
|
@ -40,7 +40,12 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
|||
};
|
||||
const docsRelativeDir = props.siteConfig.customDocsPath;
|
||||
const fsWatcher = chokidar.watch(
|
||||
[`../${docsRelativeDir}/**/*.md`, 'blog/**/*.md', 'siteConfig.js'],
|
||||
[
|
||||
`../${docsRelativeDir}/**/*.md`,
|
||||
'blog/**/*.md',
|
||||
'siteConfig.js',
|
||||
'sidebars.json',
|
||||
],
|
||||
{
|
||||
cwd: siteDir,
|
||||
ignoreInitial: true,
|
||||
|
|
|
@ -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