diff --git a/build.js b/build.js index a8a3908..2480ef8 100644 --- a/build.js +++ b/build.js @@ -640,11 +640,25 @@ const generateWebMD = async (tree, options) => { let filePromises = []; let docsifySideBar = ''; + const isExcluded = (dir) => { + if (!Array.isArray(options.EXCLUDE_SIDEBAR_FOLDER_BY_PATH)) return false; + + return options.EXCLUDE_SIDEBAR_FOLDER_BY_PATH.find((pathToExclude) => { + const isString = typeof pathToExclude === 'string'; + + if (isString) return dir.startsWith(pathToExclude); + + return false; + }); + }; + for (const item of tree) { //sidebar - docsifySideBar += `${' '.repeat(item.level - 1)}* [${item.name}](${encodeURIPath( - path.join(...path.join(item.dir).split(path.sep).splice(1), options.WEB_FILE_NAME) - )})\n`; + if (!isExcluded(item.dir)) { + docsifySideBar += `${' '.repeat(item.level - 1)}* [${item.name}](${encodeURIPath( + path.join(...path.join(item.dir).split(path.sep).splice(1), options.WEB_FILE_NAME) + )})\n`; + } let name = getFolderName(item.dir, options.ROOT_FOLDER, options.HOMEPAGE_NAME); //title diff --git a/cli.js b/cli.js index f0f717d..f34e1c6 100644 --- a/cli.js +++ b/cli.js @@ -42,6 +42,7 @@ const getOptions = (conf) => { INCLUDE_BREADCRUMBS: conf.get('includeBreadcrumbs'), INCLUDE_TABLE_OF_CONTENTS: conf.get('includeTableOfContents'), INCLUDE_LINK_TO_DIAGRAM: conf.get('includeLinkToDiagram'), + EXCLUDE_SIDEBAR_FOLDER_BY_PATH: conf.get('excludeSidebarFolderByPath'), PDF_CSS: conf.get('pdfCss') || path.join(__dirname, 'pdf.css'), DIAGRAMS_ON_TOP: conf.get('diagramsOnTop'), CHARSET: conf.get('charset'), diff --git a/cli.list.js b/cli.list.js index 087527f..46e67d1 100644 --- a/cli.list.js +++ b/cli.list.js @@ -108,6 +108,11 @@ Replace diagrams with a link: ${ ? chalk.green(currentConfiguration.INCLUDE_LINK_TO_DIAGRAM) : chalk.red('not set') } +Exclude sidebar folder by path: ${ + Array.isArray(currentConfiguration.EXCLUDE_SIDEBAR_FOLDER_BY_PATH) + ? chalk.green(currentConfiguration.EXCLUDE_SIDEBAR_FOLDER_BY_PATH) + : chalk.red('not is an array or not set') + } Place diagrams before text: ${ currentConfiguration.DIAGRAMS_ON_TOP !== undefined ? chalk.green(currentConfiguration.DIAGRAMS_ON_TOP) @@ -129,9 +134,9 @@ Charset: ${ : chalk.red('not set') } Exclude other files: ${ - currentConfiguration.EXCLUDE_OTHER_FILES !== undefined - ? chalk.green(currentConfiguration.EXCLUDE_OTHER_FILES) - : chalk.red('not set') + currentConfiguration.EXCLUDE_OTHER_FILES !== undefined + ? chalk.green(currentConfiguration.EXCLUDE_OTHER_FILES) + : chalk.red('not set') } `); return;