|
1 | 1 | import { isAbsolute, join, relative, resolve, sep } from "path";
|
2 |
| -import { BindOption } from "typedoc"; |
| 2 | +import { BindOption, ProjectReflection, Reflection } from "typedoc"; |
3 | 3 | import { Component, RendererComponent } from "typedoc/dist/lib/output/components";
|
4 | 4 | import { PageEvent } from "typedoc/dist/lib/output/events";
|
5 | 5 | import { NavigationItem } from "typedoc/dist/lib/output/models/NavigationItem";
|
6 | 6 |
|
| 7 | +const isClientModel = (model: Reflection | undefined) => model?.sources[0]?.fileName.startsWith(`clients${sep}`); |
| 8 | + |
7 | 9 | const PROJECT_ROOT = join(__dirname, "..", "..", "..", "..");
|
8 | 10 | @Component({ name: "SdkIndexLinkClientPlugin" })
|
9 | 11 | export class SdkIndexLinkClientPlugin extends RendererComponent {
|
@@ -46,6 +48,15 @@ export class SdkIndexLinkClientPlugin extends RendererComponent {
|
46 | 48 | if (page.model._skipRendering) {
|
47 | 49 | page.preventDefault();
|
48 | 50 | }
|
| 51 | + |
| 52 | + // Update the client doc link int globals.html |
| 53 | + if (page.filename.endsWith("globals.html")) { |
| 54 | + (page.model as ProjectReflection).children.filter(isClientModel).forEach((clientModel) => { |
| 55 | + const clientName = clientModel.sources[0].fileName.split(sep)[1]; |
| 56 | + const clientDocDir = clientDocsPattern.replace(/{{CLIENT}}/g, clientName); |
| 57 | + clientModel.url = join(clientDocDir, "index.html"); |
| 58 | + }); |
| 59 | + } |
49 | 60 | }
|
50 | 61 |
|
51 | 62 | /**
|
@@ -89,6 +100,6 @@ export class SdkIndexLinkClientPlugin extends RendererComponent {
|
89 | 100 | }
|
90 | 101 |
|
91 | 102 | private isClient(item: NavigationItem): boolean {
|
92 |
| - return item?.reflection?.sources[0].fileName.startsWith(`clients${sep}`); |
| 103 | + return isClientModel(item?.reflection); |
93 | 104 | }
|
94 | 105 | }
|
0 commit comments