Skip to content

Commit e848c07

Browse files
authored
fix: link tag comment with no url (#94)
1 parent a433750 commit e848c07

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

.changeset/puny-pets-refuse.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'starlight-typedoc': patch
3+
---
4+
5+
Fixes a potential error when rendering link tags in comments that reference reflections without URLs.

fixtures/basics/src/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ export interface Thing {
1111
}
1212

1313
export type Things = Thing[]
14+
15+
export type ThingWithBazAndQuux = Thing & {
16+
baz: string
17+
/**
18+
* @see {@link ThingWithBazAndQuux.baz}
19+
*/
20+
quux: number[]
21+
}

packages/starlight-typedoc/libs/theme.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ class StarlightTypeDocThemeRenderContext extends MarkdownThemeContext {
9191
(part.tag === '@link' || part.tag === '@linkcode' || part.tag === '@linkplain') &&
9292
part.target instanceof Reflection
9393
) {
94+
if (!this.router.hasUrl(part.target)) {
95+
const { target, ...rest } = part
96+
return rest
97+
}
98+
9499
return {
95100
...part,
96101
target: this.urlTo(part.target),

packages/starlight-typedoc/tests/e2e/basics/sidebar.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ test('should generate the proper items for for a single entry point', async ({ d
5858
},
5959
{
6060
label: 'Type Aliases',
61-
items: [{ name: 'Things' }],
61+
items: [{ name: 'Things' }, { name: 'ThingWithBazAndQuux' }],
6262
collapsed: true,
6363
},
6464
{

0 commit comments

Comments
 (0)