Skip to content

Commit

Permalink
MDX Basic elements
Browse files Browse the repository at this point in the history
  • Loading branch information
salvatorecriscioneweb committed Dec 18, 2023
1 parent 7411bc0 commit 6002199
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion docs/components/MDX.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
import { MDXRemote, MDXRemoteProps } from "next-mdx-remote/rsc";
import { ReactNode, ComponentProps, HTMLProps } from "react";

const defaultComponents: ComponentProps<any> = {
a: (props: HTMLProps<HTMLAnchorElement>) => (
<a {...props} className="transition-colors underline hover:text-piccolo">
{props.children}
</a>
),
strong: (props: HTMLProps<HTMLSpanElement>) => (
<span {...props} className="font-medium">
{props.children}
</span>
),
ul: (props: HTMLProps<HTMLUListElement>) => (
<ul {...props} className="list-disc ps-8">
{props.children}
</ul>
),
};

export function MDX({
markdown,
...rest
}: { markdown: string } & Omit<MDXRemoteProps, "source">) {
return <MDXRemote {...rest} source={markdown} />;
return (
<MDXRemote
{...rest}
source={markdown}
components={rest.components || defaultComponents}
/>
);
}

0 comments on commit 6002199

Please sign in to comment.