@@ -14,8 +14,6 @@ export interface HeadingProps {
14
14
as ?: any ;
15
15
}
16
16
17
- const anchorClassName = siteConfig . headerIdConfig . className ;
18
-
19
17
const Heading = forwardRefWithAs < HeadingProps , 'div' > ( function Heading (
20
18
{ as : Comp = 'div' , className, children, id, isPageAnchor = true , ...props } ,
21
19
ref
@@ -26,71 +24,31 @@ const Heading = forwardRefWithAs<HeadingProps, 'div'>(function Heading(
26
24
}
27
25
28
26
return (
29
- < >
30
- < Comp id = { id } { ...props } ref = { ref } className = { cn ( 'heading' , className ) } >
31
- { children }
32
- { isPageAnchor && (
33
- < a
34
- href = { `#${ id } ` }
35
- aria-label = { label }
36
- title = { label }
37
- className = { cn (
38
- anchorClassName ,
39
- Comp === 'h1' ? 'hidden' : 'inline-block'
40
- ) } >
41
- < svg
42
- width = "1em"
43
- height = "1em"
44
- viewBox = "0 0 13 13"
45
- xmlns = "http://www.w3.org/2000/svg"
46
- className = "text-gray-70 ml-2 h-5 w-5" >
47
- < g fill = "currentColor" fillRule = "evenodd" >
48
- < path d = "M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z" />
49
- < path d = "M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z" />
50
- </ g >
51
- </ svg >
52
- </ a >
53
- ) }
54
- </ Comp >
55
- < style jsx >
56
- { `
57
- .heading {
58
- scroll-margin-top: 2.5em;
59
- /* Space for the anchor */
60
- padding-right: 1em;
61
- }
62
- .heading:before {
63
- height: 6rem;
64
- margin-top: -6rem;
65
- visibility: hidden;
66
- content: '';
67
- }
68
-
69
- .heading .${ anchorClassName } {
70
- /* Prevent the anchor from
71
- overflowing to its own line */
72
- height: 0px;
73
- width: 0px;
74
- }
75
-
76
- .heading .${ anchorClassName } svg {
77
- display: inline;
78
- }
79
-
80
- .heading .${ anchorClassName } svg {
81
- visibility: hidden;
82
- }
83
-
84
- .heading:hover .${ anchorClassName } svg {
85
- visibility: visible;
86
- }
87
-
88
- .heading .${ anchorClassName } :focus svg {
89
- visibility: visible;
90
- }
91
- ` }
92
- </ style >
93
- </ >
27
+ < Comp id = { id } { ...props } ref = { ref } className = { cn ( 'mdx-heading' , className ) } >
28
+ { children }
29
+ { isPageAnchor && (
30
+ < a
31
+ href = { `#${ id } ` }
32
+ aria-label = { label }
33
+ title = { label }
34
+ className = { cn (
35
+ 'mdx-header-anchor' ,
36
+ Comp === 'h1' ? 'hidden' : 'inline-block'
37
+ ) } >
38
+ < svg
39
+ width = "1em"
40
+ height = "1em"
41
+ viewBox = "0 0 13 13"
42
+ xmlns = "http://www.w3.org/2000/svg"
43
+ className = "text-gray-70 ml-2 h-5 w-5" >
44
+ < g fill = "currentColor" fillRule = "evenodd" >
45
+ < path d = "M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z" />
46
+ < path d = "M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z" />
47
+ </ g >
48
+ </ svg >
49
+ </ a >
50
+ ) }
51
+ </ Comp >
94
52
) ;
95
53
} ) ;
96
54
0 commit comments