markdown open links to new window

This commit is contained in:
Kalle (Sendou)
2021-03-19 09:53:04 +02:00
parent 4486f317b3
commit 1412beb6c4
2 changed files with 8 additions and 2 deletions

View File

@@ -76,7 +76,7 @@ const Markdown: React.FC<MarkdownProps> = ({
link: (props: any) => {
const { children } = props;
return (
<MyLink isExternal {...props}>
<MyLink isExternal {...props} toNewWindow>
{children}
</MyLink>
);

View File

@@ -8,6 +8,7 @@ interface Props {
isExternal?: boolean;
prefetch?: boolean;
isColored?: boolean;
toNewWindow?: boolean;
}
const MyLink: React.FC<Props> = ({
@@ -16,12 +17,17 @@ const MyLink: React.FC<Props> = ({
isExternal,
prefetch = false,
isColored = true,
toNewWindow,
}) => {
const { themeColorShade } = useMyTheme();
if (isExternal) {
return (
<ChakraLink href={href} color={isColored ? themeColorShade : undefined}>
<ChakraLink
href={href}
color={isColored ? themeColorShade : undefined}
target={toNewWindow ? "_blank" : undefined}
>
{children}
</ChakraLink>
);