Skip to content

Commit bc0d04a

Browse files
committed
Amend AnchorHeading usage guidance
1 parent 2a55f92 commit bc0d04a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/content/docs/style-guide/components/anchor-heading.mdx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,17 @@ import { AnchorHeading } from "~/components";
1717

1818
Markdown files (including partials) have this behavior by default, applied via rehype plugins. Therefore, the `AnchorHeading` component is usually only required when writing headings yourself inside components, or when working on non-markdown files.
1919

20-
Additionally, `AnchorHeading` is useful when rendering partial files into one location where there are duplicate headings (for example, when there are multiple H3 corresponding to `/#create` in one page). `AnchorHeading` allows you to explicitly define fragments, ensuring that each heading can be referred correctly with unique anchors.
20+
To override the ID given to a heading within Markdown, add an MDX comment at the end of the line:
21+
22+
```mdx
23+
# foo {/*bar*/}
24+
```
25+
26+
It will result in the following HTML:
27+
28+
```html
29+
<a id="bar">foo</a>
30+
```
2131

2232
:::note
2333

0 commit comments

Comments
 (0)