Fix open detail in a new page
@@ -58,8 +58,8 @@ const ArrowRightBackground = ({
</Box>
);
-const isExternalLink = (href: string) =>
- href.startsWith("http") || href.startsWith("mailto");
+const isExternalLink = ({ href, target }: { href: string; target?: string }) =>
+ href.startsWith("http") || href.startsWith("mailto") || target === "_blank";
export const Link: React.SFC<LinkProps> = ({
children,
@@ -68,8 +68,15 @@ export const Link: React.SFC<LinkProps> = ({
...additionalProps
}) => {
const language = useCurrentLanguage();
+
+ if (href) {
+ href = href.replace(":language", language);
+ }
+
const isExternal =
- (href && isExternalLink(href)) || additionalProps.variant === "google";
+ (href && isExternalLink({ href, ...additionalProps })) ||
+ additionalProps.variant === "google";
+
const LinkComponent = isExternal
? ThemeLink
: ({ ...props }: { to: string }) => (
@@ -80,10 +87,6 @@ export const Link: React.SFC<LinkProps> = ({
(additionalProps as any).rel = "noopener noreferrer";
}
- if (!isExternal && href) {
- href = href.replace(":language", language);
- }
-
const component = (hovered: boolean) => (
<ThemeLink {...additionalProps} as={LinkComponent} href={href} to={href}>
{additionalProps.variant === "button" && (
