Skip to content

Commit

Permalink
Avoid general import
Browse files Browse the repository at this point in the history
  • Loading branch information
cesalberca committed Aug 24, 2024
1 parent 6d321aa commit d6d5041
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/mdx-components.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import type { MDXComponents } from 'mdx/types'

import Link from 'next/link'
import React, { type ComponentProps, createElement } from 'react'
import {
type ComponentProps,
createElement,
type LinkHTMLAttributes,
type PropsWithChildren,
type ReactNode,
} from 'react'
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
import dark from 'react-syntax-highlighter/dist/esm/styles/prism/synthwave84'
import { cn } from '@/lib/utils'

function CustomLink(props: React.LinkHTMLAttributes<HTMLAnchorElement> & React.PropsWithChildren<{ href: string }>) {
function CustomLink(props: LinkHTMLAttributes<HTMLAnchorElement> & PropsWithChildren<{ href: string }>) {
let href = props.href

if (href.startsWith('/')) {
Expand Down Expand Up @@ -90,7 +96,7 @@ const customComponents: ComponentProps<any>['components'] = {
h6: createHeading(6),
a: CustomLink,
code: Code,
pre: ({ children }: { children: React.ReactNode }) => <pre className="p-0 font-mono">{children}</pre>,
pre: ({ children }: { children: ReactNode }) => <pre className="p-0 font-mono">{children}</pre>,
}

export function useMDXComponents(components: MDXComponents): MDXComponents {
Expand Down

0 comments on commit d6d5041

Please sign in to comment.