diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-26 12:32:30 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-26 12:32:30 +0100 |
| commit | 7e12b2aa7f511e70b727bd865a0b5d0ac6723cb8 (patch) | |
| tree | 88d6ebeeaa20848e8325c6f5c2aaa8946c7ae1a6 /src | |
| parent | a09d6f1639235e668a7dd0dee5392ab1cc16dd8c (diff) | |
chore: create a Link component for MDX rendering
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/MDX/Link/Link.tsx | 23 | ||||
| -rw-r--r-- | src/components/MDX/index.tsx | 3 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/components/MDX/Link/Link.tsx b/src/components/MDX/Link/Link.tsx new file mode 100644 index 0000000..40e773b --- /dev/null +++ b/src/components/MDX/Link/Link.tsx @@ -0,0 +1,23 @@ +import { ReactChildren } from 'react'; + +const Link = ({ + children, + target, + isExternal = false, + lang, +}: { + children: ReactChildren; + target: string; + isExternal: boolean; + lang?: string; +}) => { + const className = isExternal ? 'external' : ''; + + return ( + <a href={target} className={className} hrefLang={lang}> + {children} + </a> + ); +}; + +export default Link; diff --git a/src/components/MDX/index.tsx b/src/components/MDX/index.tsx index d306f4e..5ebe6bf 100644 --- a/src/components/MDX/index.tsx +++ b/src/components/MDX/index.tsx @@ -1,3 +1,4 @@ import CodeBlock from './CodeBlock/CodeBlock'; +import Link from './Link/Link'; -export { CodeBlock }; +export { CodeBlock, Link }; |
