diff --git a/packages/typedoc-plugin-markdown/src/theme/context/helpers/get-comment-parts.ts b/packages/typedoc-plugin-markdown/src/theme/context/helpers/get-comment-parts.ts index f3e379628..002f9764c 100644 --- a/packages/typedoc-plugin-markdown/src/theme/context/helpers/get-comment-parts.ts +++ b/packages/typedoc-plugin-markdown/src/theme/context/helpers/get-comment-parts.ts @@ -63,7 +63,8 @@ export function getCommentParts( } else { const fileName = this.page.project.files.getName(part.target); if (fileName) { - url = this.getRelativeUrl(`_media/${fileName}`); + const anchor = part.targetAnchor ? `#${part.targetAnchor}` : ''; + url = this.getRelativeUrl(`_media/${fileName}${anchor}`); } } diff --git a/packages/typedoc-plugin-markdown/test/fixtures/src/comments/index.ts b/packages/typedoc-plugin-markdown/test/fixtures/src/comments/index.ts index 223d87c17..791971119 100644 --- a/packages/typedoc-plugin-markdown/test/fixtures/src/comments/index.ts +++ b/packages/typedoc-plugin-markdown/test/fixtures/src/comments/index.ts @@ -25,6 +25,7 @@ * Relative Links: * * - [Relative Document](../../PROJECT_DOC_1.md) + * - [Relative Document With Anchor](../../PROJECT_DOC_1.md#anchor) * * Relative Image Links: * diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap index 15233953d..5eb844450 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap @@ -41,6 +41,7 @@ External links: Relative Links: - [Relative Document](_media/PROJECT_DOC_1.md) +- [Relative Document With Anchor](_media/PROJECT_DOC_1.md#anchor) Relative Image Links: