Add ability to specify sub categories in sidebar.json (#891)

This commit is contained in:
Will Brock 2018-08-06 21:58:48 -04:00 committed by Yangshun Tay
parent dd9d05c84d
commit 16087b4428
14 changed files with 534 additions and 87 deletions

View file

@ -64,10 +64,30 @@ function autoPrefixCss(cssContent) {
.then(result => result.css);
}
// Validate the docs in the sidebar are valid
function validateSidebar(metadata, pages) {
if (metadata.next) {
if (!pages[metadata.next]) {
throw new Error(
metadata.version
? `Improper sidebars file for version ${
metadata.version
}, document with id '${
metadata.next
}' not found. Make sure that all documents with ids specified in this version's sidebar file exist and that no ids are repeated.`
: `Improper sidebars.json file, document with id '${
metadata.next
}' not found. Make sure that documents with the ids specified in sidebars.json exist and that no ids are repeated.`
);
}
}
}
module.exports = {
getSubDir,
getLanguage,
isSeparateCss,
minifyCss,
autoPrefixCss,
validateSidebar,
};