mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
feat(v2): enable subcategories (#1021)
* feat(v2): enable subcategories * nits * eslint issue https://github.com/prettier/prettier/issues/3734
This commit is contained in:
parent
954456088c
commit
f62029c30e
9 changed files with 150 additions and 43 deletions
|
@ -9,11 +9,26 @@ module.exports = function createOrder(allSidebars = {}) {
|
|||
|
||||
let ids = [];
|
||||
const categoryOrder = [];
|
||||
const subCategoryOrder = [];
|
||||
Object.keys(categories).forEach(category => {
|
||||
ids = ids.concat(categories[category]);
|
||||
// eslint-disable-next-line
|
||||
for (let i = 0; i < categories[category].length; i++) {
|
||||
categoryOrder.push(category);
|
||||
if (Array.isArray(categories[category])) {
|
||||
ids = ids.concat(categories[category]);
|
||||
|
||||
// eslint-disable-next-line
|
||||
for (let i = 0; i < categories[category].length; i++) {
|
||||
categoryOrder.push(category);
|
||||
subCategoryOrder.push(undefined);
|
||||
}
|
||||
} else {
|
||||
Object.keys(categories[category]).forEach(subCategory => {
|
||||
ids = ids.concat(categories[category][subCategory]);
|
||||
|
||||
// eslint-disable-next-line
|
||||
for (let i = 0; i < categories[category][subCategory].length; i++) {
|
||||
categoryOrder.push(category);
|
||||
subCategoryOrder.push(subCategory);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -29,6 +44,7 @@ module.exports = function createOrder(allSidebars = {}) {
|
|||
next,
|
||||
sidebar,
|
||||
category: categoryOrder[i],
|
||||
subCategory: subCategoryOrder[i],
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue