Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ulixee
GitHub Repository: ulixee/secret-agent
Path: blob/main/website/src/lib/generateLinks.ts
1029 views
1
import kebabCase from 'lodash.kebabcase';
2
3
const links = require('../../docs/links.yaml');
4
5
export default function generateLinks() {
6
links.forEach((group: any) => {
7
group.link = `/docs/${kebabCase(group.title)}`;
8
group.items = group.items.map((item: any) => {
9
if (item.items) {
10
item.link = `${group.link}/${kebabCase(item.title)}`;
11
item.editLink = `/docs/${group.title}/${item.title}`;
12
item.items = item.items.map((itm: any) => {
13
if (typeof itm === 'string') {
14
return {
15
title: itm,
16
link: `${item.link}/${kebabCase(itm)}`,
17
};
18
}
19
return itm;
20
});
21
} else if (typeof item === 'string') {
22
return {
23
title: item,
24
link: `${group.link}/${kebabCase(item)}`,
25
editLink: `/docs/${group.title}/${item}`,
26
};
27
}
28
return item;
29
});
30
});
31
return links;
32
}
33
34