0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(console): external links in readme should be opened in new tab

This commit is contained in:
Charles Zhao 2022-07-15 12:50:29 +08:00
parent f1b241c864
commit 23ff0bf21d
No known key found for this signature in database
GPG key ID: 4858774754C92DF2

View file

@ -57,6 +57,15 @@ const Markdown = ({ className, children }: Props) => {
img: ({ src, alt }) => {
return <GithubRawImage src={src} alt={alt} />;
},
a: ({ href, children }) => {
const isExternalLink = href?.startsWith('http');
return (
<a href={href} target={isExternalLink ? '_blank' : '_self'} rel="noopener">
{children}
</a>
);
},
h1: ({ children }) => <h1 id={generateTocId(String(children))}>{children}</h1>,
h2: ({ children }) => <h2 id={generateTocId(String(children))}>{children}</h2>,
h3: ({ children }) => <h3 id={generateTocId(String(children))}>{children}</h3>,