Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 00deef5

Browse files
committed
fix(docz-theme-default): use docz link when href is internal
1 parent e8e8ec8 commit 00deef5

File tree

1 file changed

+17
-1
lines changed
  • packages/docz-theme-default/src/components/ui

1 file changed

+17
-1
lines changed

packages/docz-theme-default/src/components/ui/Link.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import * as React from 'react'
2+
import { SFC } from 'react'
13
import styled from 'react-emotion'
4+
import { Link as BaseLink } from 'docz'
25

3-
export const Link = styled('a')`
6+
export const LinkStyled = styled('a')`
47
&,
58
&:visited,
69
&:active {
@@ -12,3 +15,16 @@ export const Link = styled('a')`
1215
color: ${p => p.theme.docz.colors.link};
1316
}
1417
`
18+
19+
type LinkProps = React.AnchorHTMLAttributes<any>
20+
21+
export const Link: SFC<LinkProps> = ({ href, ...props }) => {
22+
const isInternal = href && href.startsWith('/')
23+
const Component = isInternal ? LinkStyled.withComponent(BaseLink) : LinkStyled
24+
25+
return isInternal ? (
26+
<Component {...props} to={href} />
27+
) : (
28+
<Component {...props} href={href} />
29+
)
30+
}

0 commit comments

Comments
 (0)