File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ export const BaseLink = forwardRef(function Link(
67
67
const isPdf = url . isPdf ( href )
68
68
const isExternal = url . isExternal ( href )
69
69
const isInternalPdf = isPdf && ! isExternal
70
+ const isHash = url . isHash ( href )
70
71
71
72
// Get proper download link for internally hosted PDF's & static files (ex: whitepaper)
72
73
// Opens in separate window.
@@ -119,6 +120,27 @@ export const BaseLink = forwardRef(function Link(
119
120
)
120
121
}
121
122
123
+ if ( isHash ) {
124
+ return (
125
+ < ChakraLink
126
+ onClick = { ( e ) => {
127
+ e . stopPropagation ( )
128
+ trackCustomEvent (
129
+ customEventOptions ?? {
130
+ eventCategory : "Link" ,
131
+ eventAction : "Clicked" ,
132
+ eventName : "Clicked on hash link" ,
133
+ eventValue : href ,
134
+ }
135
+ )
136
+ } }
137
+ { ...commonProps }
138
+ >
139
+ { children }
140
+ </ ChakraLink >
141
+ )
142
+ }
143
+
122
144
return (
123
145
< NextLink
124
146
locale = { locale }
Original file line number Diff line number Diff line change @@ -33,3 +33,5 @@ export const isHrefActive = (
33
33
? pathname . startsWith ( cleanHref )
34
34
: pathname === cleanHref
35
35
}
36
+
37
+ export const isHash = ( href : string ) : boolean => href . startsWith ( "#" )
You can’t perform that action at this time.
0 commit comments