Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions src/lib/output/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,27 @@ export abstract class BaseRouter implements Router {
}
}

protected createAnchor(
target: Reflection,
pageTarget: RouterTarget,
): string {
const parts = [target.name];
while (target.parent && target.parent !== pageTarget) {
target = target.parent;
// Avoid duplicate names for signatures and useless __type in anchors
if (
!target.kindOf(
ReflectionKind.TypeLiteral |
ReflectionKind.FunctionOrMethod,
)
) {
parts.unshift(target.name);
}
}

return this.getSlugger(pageTarget).slug(parts.join("."));
}

protected buildAnchors(
target: RouterTarget,
pageTarget: RouterTarget,
Expand Down Expand Up @@ -387,24 +408,7 @@ export abstract class BaseRouter implements Router {
}

if (!target.kindOf(ReflectionKind.TypeLiteral)) {
let refl: Reflection | undefined = target;
const parts = [refl.name];
while (refl.parent && refl.parent !== pageTarget) {
refl = refl.parent;
// Avoid duplicate names for signatures and useless __type in anchors
if (
!refl.kindOf(
ReflectionKind.TypeLiteral |
ReflectionKind.FunctionOrMethod,
)
) {
parts.unshift(refl.name);
}
}

const anchor = this.getSlugger(pageTarget).slug(
parts.join("."),
);
const anchor = this.createAnchor(target, pageTarget);

this.fullUrls.set(
target,
Expand Down
Loading