vuepress-plugin-typedoc
Version:
A VuePress plugin to build API documentation with TypeDoc.
52 lines (51 loc) • 1.68 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({
title: navigationItem.title,
children: (_a = navigationItem.children) === null || _a === void 0 ? void 0 : _a.map((navItem) => {
return [
getUrlKey(navItem.url),
sidebarOptions.fullNames
? navItem.title
: getShortName(navItem.title),
];
}),
});
}
else {
navJson.push([
getUrlKey(navigationItem.url) === 'README'
? `/${outDir}/`
: `/${outDir}/modules`,
navigationItem.title,
]);
}
});
if (sidebarOptions.parentCategory &&
sidebarOptions.parentCategory !== 'none') {
return [
{
title: sidebarOptions.parentCategory,
children: navJson,
initialOpenGroupIndex: -1,
collapsable: false,
},
];
}
return navJson;
};
exports.getSidebarJson = getSidebarJson;
const getShortName = (title) => {
const longTitle = title.split('.');
return longTitle[longTitle.length - 1];
};
const getUrlKey = (url) => {
return url.replace('.md', '');
};
;