11import React from 'react'
22import { Link as PrimerLink } from '@primer/react'
3- import { Link as GatsbyLink } from 'gatsby'
43import omit from '../util/omit'
54
65const FALLBACK = `http://_${ Math . random ( ) . toString ( ) . slice ( 2 ) } ._${ Math . random ( ) . toString ( ) . slice ( 2 ) } `
@@ -22,15 +21,26 @@ const getLocalPath = href => {
2221 return null
2322}
2423
25- const GatsbyLinkWithoutSxProps = React . forwardRef ( function GatsbyLinkWithoutSxProps ( props , ref ) {
26- return < GatsbyLink ref = { ref } { ...omit ( props , 'sx' , 'underline' , 'hoverColor' , 'muted' ) } />
24+ const BasicLinkAdapter = React . forwardRef ( function BasicLinkAdapter ( props , ref ) {
25+ const { to, ...otherProps } = props
26+ // Convert 'to' prop to 'href' for regular anchor tags
27+ return (
28+ < a
29+ ref = { ref }
30+ href = { to }
31+ { ...omit ( otherProps , 'sx' , 'underline' , 'hoverColor' , 'muted' ) }
32+ aria-label = { otherProps [ 'aria-label' ] || 'Link' }
33+ >
34+ { props . children || 'Link' }
35+ </ a >
36+ )
2737} )
2838
2939const Link = React . forwardRef ( function Link ( { to, href, ...props } , ref ) {
3040 const localPath = getLocalPath ( href )
3141
3242 if ( to || localPath !== null ) {
33- return < PrimerLink ref = { ref } as = { GatsbyLinkWithoutSxProps } to = { to || localPath } { ...props } />
43+ return < PrimerLink ref = { ref } as = { BasicLinkAdapter } to = { to || localPath } { ...props } />
3444 }
3545
3646 return < PrimerLink ref = { ref } href = { href } { ...props } />
0 commit comments