vuepress-plugin-typedoc
Version:
A VuePress plugin to build API documentation with TypeDoc.
52 lines (51 loc) • 1.69 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSidebarJson = void 0;
const getSidebarJson = (navigation, sidebarOptions, outDir) => {
var _a;
const navJson = [];
(_a = navigation.children) === null || _a === void 0 ? void 0 : _a.forEach((navigationItem) => {
var _a;
if (navigationItem.isLabel) {
navJson.push({
text: navigationItem.title,
collapsible: true,
children: (_a = navigationItem.children) === null || _a === void 0 ? void 0 : _a.map((navItem) => {
return {
link: `/${outDir}/${navItem.url}`,
text: sidebarOptions.fullNames
? navItem.title
: getShortName(navItem.title),
};
}),
});
}
else {
navJson.push({
link: getUrlKey(navigationItem.url) === 'README.md'
? `/${outDir}/`
: `/${outDir}/modules.md`,
text: navigationItem.title,
});
}
});
if (sidebarOptions.parentCategory &&
sidebarOptions.parentCategory !== 'none') {
return [
{
text: sidebarOptions.parentCategory,
children: navJson,
collapsible: false,
},
];
}
return navJson;
};
exports.getSidebarJson = getSidebarJson;
const getShortName = (title) => {
const longTitle = title.split('.');
return longTitle[longTitle.length - 1];
};
const getUrlKey = (url) => {
return url;
};
;