Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): add the ability to exclude folder of the sidebar #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
11 changes: 8 additions & 3 deletions cli.list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down