Skip to content

Commit 0ff5bbe

Browse files
authored
Add hover links to heading levels 4, 5, and 6 (#1064)
Add to heading levels 4, 5, and 6 the same hover-over links and clickable-ness that heading levels 1-3 enjoy. This does not add them to the in-page table of contents, but simply lets users easily copy deep links straight to the sections. https://github.com/user-attachments/assets/e03428c9-aba4-439d-904b-acce74225da0
1 parent f338b3b commit 0ff5bbe

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/components/MdxComponents.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ const MdxComponents = (version?: string) => {
5353
h3: (props: any) => {
5454
return <Heading level="3" id={props.id} props={props} />;
5555
},
56+
h4: (props: any) => {
57+
return <Heading level="4" id={props.id} props={props} />;
58+
},
59+
h5: (props: any) => {
60+
return <Heading level="5" id={props.id} props={props} />;
61+
},
62+
h6: (props: any) => {
63+
return <Heading level="6" id={props.id} props={props} />;
64+
},
5665
img: (props: any) => {
5766
return <img className="rounded-xl" {...props} />;
5867
},

src/components/mdx/Heading.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ function Anchor({id, children}: {id: string; children: ReactNode}) {
5858
}
5959

6060
interface HeadingProps {
61-
level?: '2' | '3';
61+
level?: '2' | '3' | '4' | '5' | '6';
6262
id: string;
6363
props: any;
6464
}
6565

6666
export function Heading({level = '2', id, props}: HeadingProps) {
67-
let Component = `h${level}` as 'h2' | 'h3';
67+
let Component = `h${level}` as 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
6868
return (
6969
<Component {...props}>
7070
<Anchor id={id}>{props.children}</Anchor>

0 commit comments

Comments
 (0)