@mdx-js/react#MDXProviderComponentsProp TypeScript Examples

The following examples show how to use @mdx-js/react#MDXProviderComponentsProp. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: mdx-components.tsx    From website with Apache License 2.0 4 votes vote down vote up
mdxComponents: MDXProviderComponentsProp = {
  h1: ({ children }) => (
    <Heading look="h100">
      <Anchor>{children}</Anchor>
    </Heading>
  ),
  h2: ({ children }) => (
    <Heading css={{ marginTop: 68 }} look="h200">
      <Anchor>{children}</Anchor>
    </Heading>
  ),
  h3: ({ children }) => (
    <Heading css={{ marginTop: 60 }} look="h300">
      <Anchor>{children} </Anchor>
    </Heading>
  ),
  h4: ({ children }) => (
    <Heading css={{ marginTop: 52 }} look="h400">
      <Anchor>{children}</Anchor>
    </Heading>
  ),
  h5: ({ children }) => (
    <Heading css={{ marginTop: 44 }} look="h500">
      <Anchor>{children} </Anchor>
    </Heading>
  ),
  p: ({ children }) => (
    <P>
      <Text>{children}</Text>
    </P>
  ),
  pre: ({ children }) => children,
  code: ({ children, className }) => (
    <VerticalStack spacing={2}>
      <CodeBlock language={className ? className.split('-')[1] : undefined}>
        {children}
      </CodeBlock>
    </VerticalStack>
  ),
  hr: () => <Hr />,
  inlineCode: ({ children }) => <Code>{children}</Code>,
  a: ({ href, children, ...props }) =>
    href.startsWith('http') || href.startsWith('./') || href.startsWith('#') ? (
      <a
        href={href}
        css={{
          color: colors.primary,
          textDecoration: 'none',
          ':hover': { textDecoration: 'underline' },
        }}
        target={href.startsWith('#') ? undefined : '_blank'}
        rel="noopener noreferrer"
        {...props}>
        {children}
      </a>
    ) : (
      <Link
        to={href}
        css={{
          color: colors.primary,
          textDecoration: 'none',
          ':hover': { textDecoration: 'underline' },
        }}
        {...props}>
        {children}
      </Link>
    ),
  blockquote: (props) => <Quote {...props} />,
  strong: (props) => <strong css={{ fontWeight: 500 }} {...props} />,
  ol: (props) => <VerticalStack as="ol" spacing={4} gap={2} {...props} />,
  ul: (props) => <VerticalStack as="ul" spacing={4} gap={2} {...props} />,
  li: (props) => <Text as="li" {...props} />,
  td: (props) => (
    <td>
      <Text as="td" {...props} />
    </td>
  ),
  th: (props) => (
    <th>
      <Text as="th" weight="bold" {...props} />
    </th>
  ),
  table: (props) => <table {...props} css={{ marginTop: '4rem' }} />,
}