|
| 1 | +// @ts-check |
| 2 | + |
| 3 | +/** |
| 4 | + * Local plugin to tweak TypeDoc output for nextra docs |
| 5 | + * |
| 6 | + * @param {import("typedoc").Application} app |
| 7 | + */ |
1 | 8 | export function load(app) {
|
2 | 9 | app.converter.addUnknownSymbolResolver((ref) => {
|
3 | 10 | if (ref.moduleSource === 'typedoc') {
|
4 |
| - const symbol = ref.symbolReference.path[0].path; |
| 11 | + const symbol = |
| 12 | + ref?.symbolReference?.path && ref?.symbolReference?.path[0].path; |
5 | 13 | const enums = ['ReflectionKind'];
|
6 | 14 | const configuration = [
|
7 | 15 | 'DeclarationOption',
|
@@ -56,24 +64,28 @@ export function load(app) {
|
56 | 64 | 'QueryType',
|
57 | 65 | ];
|
58 | 66 |
|
59 |
| - if (models.includes(symbol)) { |
60 |
| - return `https://typedoc.org/api/classes/Models.${symbol}.html`; |
61 |
| - } |
62 |
| - if (classes.includes(symbol)) { |
63 |
| - return `https://typedoc.org/api/classes/${symbol}.html`; |
64 |
| - } |
65 |
| - if (enums.includes(symbol)) { |
66 |
| - return `https://typedoc.org/api/enums/Models.${symbol}-1.html`; |
67 |
| - } |
68 |
| - if (interfaces.includes(symbol)) { |
69 |
| - return `https://typedoc.org/api/${interfaces}/TypeDocOptions.html`; |
70 |
| - } |
71 |
| - if (configuration.includes(symbol)) { |
72 |
| - return `https://typedoc.org/api/types/Configuration.${symbol}.html`; |
73 |
| - } |
74 |
| - if (types.includes(symbol)) { |
75 |
| - return `https://typedoc.org/api/types/${symbol}.DeclarationOption.html`; |
| 67 | + if (symbol) { |
| 68 | + if (models.includes(symbol)) { |
| 69 | + return `https://typedoc.org/api/classes/Models.${symbol}.html`; |
| 70 | + } |
| 71 | + if (classes.includes(symbol)) { |
| 72 | + return `https://typedoc.org/api/classes/${symbol}.html`; |
| 73 | + } |
| 74 | + if (enums.includes(symbol)) { |
| 75 | + return `https://typedoc.org/api/enums/Models.${symbol}-1.html`; |
| 76 | + } |
| 77 | + if (interfaces.includes(symbol)) { |
| 78 | + return `https://typedoc.org/api/${interfaces}/TypeDocOptions.html`; |
| 79 | + } |
| 80 | + if (configuration.includes(symbol)) { |
| 81 | + return `https://typedoc.org/api/types/Configuration.${symbol}.html`; |
| 82 | + } |
| 83 | + if (types.includes(symbol)) { |
| 84 | + return `https://typedoc.org/api/types/${symbol}.DeclarationOption.html`; |
| 85 | + } |
76 | 86 | }
|
| 87 | + |
| 88 | + return ''; |
77 | 89 | }
|
78 | 90 | });
|
79 | 91 | }
|
0 commit comments