mirror of
https://github.com/tauri-apps/rustdocusaurus.git
synced 2026-02-04 18:51:19 +01:00
28 lines
692 B
JavaScript
28 lines
692 B
JavaScript
const { itemsReference } = require("./common");
|
|
const keys = Object.keys(itemsReference);
|
|
|
|
const generateSidebar = (contents, label, originPath) => {
|
|
const out = {
|
|
label,
|
|
type: "category",
|
|
items: [],
|
|
};
|
|
keys.forEach((key) => {
|
|
if (key === "module") {
|
|
for (const path in contents.module) {
|
|
const moduleLabel = path.split("/").pop();
|
|
out.items.push(generateSidebar(contents.module[path], moduleLabel, originPath));
|
|
}
|
|
return;
|
|
}
|
|
contents[key].forEach((item) => {
|
|
out.items.push(
|
|
item.path.replace(originPath, `api/rust/`).replace(".html", "")
|
|
);
|
|
});
|
|
});
|
|
return out;
|
|
};
|
|
|
|
module.exports = generateSidebar;
|