fix(v2): throw error if first level item of a sidebar is not category (#1994)

This commit is contained in:
Endi 2019-11-14 23:36:15 +07:00 committed by GitHub
parent 472a1a660c
commit 4e5a03fb88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 0 deletions

View file

@ -39,6 +39,13 @@ function normalizeCategory(
category: SidebarItemCategoryRaw,
level = 0,
): SidebarItemCategory {
if (level === 0 && category.type !== 'category') {
throw new Error(
`Error loading ${JSON.stringify(
category,
)}. First level item of a sidebar must be a category`,
);
}
assertItem(category, ['items', 'label']);
if (!Array.isArray(category.items)) {