Skip to content

Commit

Permalink
fix(AnchorLink): Hook into Docusaurus' broken links API to inform abo…
Browse files Browse the repository at this point in the history
…ut anchors produced by this plugin. (#135)

fix(AnchorLink): Anchor links now use Docusaurus's Link component, instead of a vanilla "a".
  • Loading branch information
boenrobot committed Feb 11, 2024
1 parent b7612a4 commit fb43b78
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/plugin/src/components/AnchorLink.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import Link from '@docusaurus/Link';
import useBrokenLinks from '@docusaurus/useBrokenLinks';

export interface AnchorLinkProps {
id: string;
}

export function AnchorLink({ id }: AnchorLinkProps) {
useBrokenLinks().collectAnchor(id);

return (
<a className="tsd-anchor" href={`#${id}`}>
<Link className="tsd-anchor" href={`#${id}`}>
<span className="tsd-anchor-id" id={id} />
<i className="codicon codicon-symbol-numeric" />
</a>
</Link>
);
}

0 comments on commit fb43b78

Please sign in to comment.