feat(website): add anchor links to docs headings

Hover a heading to reveal a # link on the left that updates the URL
hash without layout shift, matching GitHub README behavior.
This commit is contained in:
Mohamed Boudra
2026-05-01 21:11:14 +07:00
parent f2a23039cb
commit 65b814c7dc
6 changed files with 151 additions and 2 deletions
+20
View File
@@ -0,0 +1,20 @@
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import rehypeSlug from "rehype-slug";
import type { PluggableList } from "unified";
export const docsRehypePlugins: PluggableList = [
rehypeSlug,
[
rehypeAutolinkHeadings,
{
behavior: "prepend",
properties: { className: "heading-anchor", ariaLabel: "Link to this section" },
content: {
type: "element",
tagName: "span",
properties: { className: "heading-anchor-icon", ariaHidden: "true" },
children: [{ type: "text", value: "#" }],
},
},
],
];