Hover a heading to reveal a # link on the left that updates the URL hash without layout shift, matching GitHub README behavior.
21 lines
582 B
TypeScript
21 lines
582 B
TypeScript
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: "#" }],
|
|
},
|
|
},
|
|
],
|
|
];
|