Skip to content

Commit

Permalink
fix(docz-theme-default): use docz link when href is internal
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Aug 2, 2018
1 parent e8e8ec8 commit 00deef5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/docz-theme-default/src/components/ui/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as React from 'react'
import { SFC } from 'react'
import styled from 'react-emotion'
import { Link as BaseLink } from 'docz'

export const Link = styled('a')`
export const LinkStyled = styled('a')`
&,
&:visited,
&:active {
Expand All @@ -12,3 +15,16 @@ export const Link = styled('a')`
color: ${p => p.theme.docz.colors.link};
}
`

type LinkProps = React.AnchorHTMLAttributes<any>

export const Link: SFC<LinkProps> = ({ href, ...props }) => {
const isInternal = href && href.startsWith('/')
const Component = isInternal ? LinkStyled.withComponent(BaseLink) : LinkStyled

return isInternal ? (
<Component {...props} to={href} />
) : (
<Component {...props} href={href} />
)
}

0 comments on commit 00deef5

Please sign in to comment.