mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-25 15:07:17 +02:00
feat:docs translation + versioning 💥
This commit is contained in:
parent
31d333b82f
commit
0f38ae3979
20 changed files with 1133 additions and 520 deletions
|
@ -1,34 +1,36 @@
|
|||
// 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]);
|
||||
for (let i = 0; i < categories[category].length; i++) {
|
||||
categoryOrder.push(category);
|
||||
}
|
||||
});
|
||||
|
||||
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;
|
||||
};
|
||||
// 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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue