File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
packages/gitbook/src/components Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,9 @@ export async function RecordCard(
165
165
166
166
if ( target && targetRef ) {
167
167
return (
168
+ // We don't use `Link` directly here because we could end up in a situation where
169
+ // a link is rendered inside a link, which is not allowed in HTML.
170
+ // It causes an hydration error in React.
168
171
< LinkBox href = { target . href } className = { tcls ( style , 'hover:before:ring-tint-12/5' ) } >
169
172
< LinkOverlay
170
173
href = { target . href }
Original file line number Diff line number Diff line change @@ -76,6 +76,10 @@ export const Link = React.forwardRef(function Link(
76
76
) ;
77
77
} ) ;
78
78
79
+ /**
80
+ * A box used to contain a link overlay.
81
+ * It is used to create a clickable area that can contain other elements.
82
+ */
79
83
export const LinkBox = React . forwardRef ( function LinkBox (
80
84
props : React . BaseHTMLAttributes < HTMLDivElement > ,
81
85
ref : React . Ref < HTMLDivElement >
@@ -88,6 +92,11 @@ export const LinkBox = React.forwardRef(function LinkBox(
88
92
) ;
89
93
} ) ;
90
94
95
+ /**
96
+ * A link overlay that can be used to create a clickable area on top of other elements.
97
+ * It is used to create a link that covers the entire area of the element without encapsulating it in a link tag.
98
+ * This is useful to avoid nesting links inside links.
99
+ */
91
100
export const LinkOverlay = React . forwardRef ( function LinkOverlay (
92
101
props : LinkProps ,
93
102
ref : React . Ref < HTMLAnchorElement >
You can’t perform that action at this time.
0 commit comments