Skip to content

Commit

Permalink
Generate external links from mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert committed Dec 12, 2024
1 parent 7f3021a commit ca93c6f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion docs/src/mdx-components.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as React from 'react';
import clsx from 'clsx';
import { ExternalLinkIcon } from 'docs/src/components/icons/ExternalLinkIcon';
import { DemoLoader } from './components/demo/NewDemoLoader';
import * as CodeBlock from './components/CodeBlock';
import * as Table from './components/Table';
Expand All @@ -17,7 +19,22 @@ interface MDXComponents {
}

export const mdxComponents: MDXComponents = {
a: (props) => <Link {...props} />,
a: (props) => {
if (props.href.startsWith('http')) {
return (
<Link
target="_blank"
rel="noopener"
{...props}
className={clsx(props.className, 'inline-flex items-center gap-1')}
>
{props.children}
<ExternalLinkIcon className="" />
</Link>
);
}
return <Link {...props} />;
},
code: (props) => <Code className="data-[inline]:mx-[0.1em]" {...props} />,
h1: (props) => (
<React.Fragment>
Expand Down

0 comments on commit ca93c6f

Please sign in to comment.