MCPcopy Create free account
hub / github.com/github/docs / Link

Function Link

components/Link.tsx:7–33  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

5
6type Props = { locale?: string; disableClientTransition?: boolean } & ComponentProps<'a'>
7export function Link(props: Props) {
8 const { href, locale, disableClientTransition = false, ...restProps } = props
9
10 if (!href && NODE_ENV !== 'production') {
11 console.warn('Missing href on Link')
12 }
13
14 const isExternal = href?.startsWith('http') || href?.startsWith('//')
15
16 if (disableClientTransition) {
17 return (
18 /* eslint-disable-next-line jsx-a11y/anchor-has-content */
19 <a
20 href={locale ? `/${locale}${href}` : href}
21 rel={isExternal ? 'noopener' : ''}
22 {...restProps}
23 />
24 )
25 }
26
27 return (
28 <NextLink href={locale ? `/${locale}${href}` : href || ''} locale={locale || false}>
29 {/* eslint-disable-next-line jsx-a11y/anchor-has-content */}
30 <a rel={isExternal ? 'noopener' : ''} {...restProps} />
31 </NextLink>
32 )
33}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected