mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-02 11:47:23 +02:00
* Prettify all JavaScript files * Make trailingComma all * Delete v2/.prettierignore * Remove v2 Prettier commands in package.json
36 lines
949 B
JavaScript
36 lines
949 B
JavaScript
// build the docs meta such as next, previous, category and sidebar
|
|
module.exports = function createOrder(allSidebars = {}) {
|
|
const order = {};
|
|
if (!allSidebars) {
|
|
return order;
|
|
}
|
|
Object.keys(allSidebars).forEach(sidebar => {
|
|
const categories = allSidebars[sidebar];
|
|
|
|
let ids = [];
|
|
const categoryOrder = [];
|
|
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);
|
|
}
|
|
});
|
|
|
|
// eslint-disable-next-line
|
|
for (let i = 0; i < ids.length; i++) {
|
|
const id = ids[i];
|
|
let previous;
|
|
let next;
|
|
if (i > 0) previous = ids[i - 1];
|
|
if (i < ids.length - 1) next = ids[i + 1];
|
|
order[id] = {
|
|
previous,
|
|
next,
|
|
sidebar,
|
|
category: categoryOrder[i],
|
|
};
|
|
}
|
|
});
|
|
return order;
|
|
};
|