-
Notifications
You must be signed in to change notification settings - Fork 53
/
sidebars.js
38 lines (34 loc) · 920 Bytes
/
sidebars.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const utils = require("@docusaurus/utils");
async function generateSidebars() {
const product_sidebars = await utils.Globby("./products/**/sidebars.js");
let sidebar = {};
const filters = process.env.PRODUCTS_INCLUDE
? process.env.PRODUCTS_INCLUDE.split(",")
: undefined;
if (filters) {
filters.forEach((filter) => {
const sidebars_path = product_sidebars.filter((sidebar) =>
sidebar.includes(filter)
)[0];
if (sidebars_path) {
sidebar = Object.assign(sidebar, require(sidebars_path));
}
});
} else {
product_sidebars.forEach((product_sidebar) => {
sidebar = Object.assign(sidebar, require(product_sidebar));
});
}
return sidebar;
}
const sidebars = async () => {
try {
return await generateSidebars();
} catch (err) {
console.log(err);
return false;
}
};
module.exports = sidebars().then((s) => {
return s;
});