Skip to content

Commit 79f7a6e

Browse files
committed
fix(core): preserve anchors in project document links
1 parent 11b6831 commit 79f7a6e

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

packages/typedoc-plugin-markdown/src/theme/context/helpers/get-comment-parts.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ export function getCommentParts(
6363
} else {
6464
const fileName = this.page.project.files.getName(part.target);
6565
if (fileName) {
66-
url = this.getRelativeUrl(`_media/${fileName}`);
66+
const anchor = part.targetAnchor ? `#${part.targetAnchor}` : '';
67+
url = this.getRelativeUrl(`_media/${fileName}${anchor}`);
6768
}
6869
}
6970

packages/typedoc-plugin-markdown/test/fixtures/src/comments/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* Relative Links:
2626
*
2727
* - [Relative Document](../../PROJECT_DOC_1.md)
28+
* - [Relative Document With Anchor](../../PROJECT_DOC_1.md#anchor)
2829
*
2930
* Relative Image Links:
3031
*

packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ External links:
4141
Relative Links:
4242
4343
- [Relative Document](_media/PROJECT_DOC_1.md)
44+
- [Relative Document With Anchor](_media/PROJECT_DOC_1.md#anchor)
4445
4546
Relative Image Links:
4647

0 commit comments

Comments
 (0)