feat: sub-categories in sidebar.json (#892)

* Add ability to specify sub categories in sidebar.json

* move v1 files to correct place

* refactor implementation

* refactor naming for implementation clarity
This commit is contained in:
Will Brock 2018-10-08 04:09:29 -04:00 committed by Endilie Yacop Sucipto
parent d052feec40
commit 954456088c
14 changed files with 535 additions and 88 deletions

View file

@ -66,10 +66,30 @@ function autoPrefixCss(cssContent) {
.then(result => result.css);
}
// Validate the docs in the sidebar are valid
function validateSidebar(metadata, sidebarMetadatas) {
if (metadata.next) {
if (!sidebarMetadatas[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,
};