Skip to content

Commit

Permalink
docs: add useBrokenLink hook section
Browse files Browse the repository at this point in the history
  • Loading branch information
OzakIOne committed Dec 21, 2023
1 parent 1ad40e9 commit aa204ab
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions website/docs/docusaurus-core.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,38 @@ const MyComponent = () => {
};
```

### `useBrokenLinks` {#useBrokenLinks}

React hook to access the BrokenLinks context. The context provides methods for collecting and managing information about anchors and links.

Usage example:

```js
import useBrokenLinks from '@docusaurus/useBrokenLinks';

// MyHeading component
export default function MyHeading({id, ...props}): JSX.Element {
const brokenLinks = useBrokenLinks();

brokenLinks.collectAnchor(id);

return <h1 id={id}>Heading</h1>;
}
```

```js
import useBrokenLinks from '@docusaurus/useBrokenLinks';

// MyLink component
export default function MyLink({targetLink, ...props}): JSX.Element {
const brokenLinks = useBrokenLinks();

brokenLinks.collectLink(targetLink);

return <a href={targetLink}>Link</a>;
}
```

## Functions {#functions}

### `interpolate` {#interpolate-1}
Expand Down

0 comments on commit aa204ab

Please # to comment.