Skip to content

Commit

Permalink
Add proper types for helper props
Browse files Browse the repository at this point in the history
  • Loading branch information
isoscelesxyz committed Sep 17, 2024
1 parent a0c52e3 commit 33528f1
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions content/helpers.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
/**
* Formatting helpers for MDX Provider
*/
const MDXComponents = {
h1: (props) => (
import React from "react";

import { MDXProvider } from "@mdx-js/react";

type Components = Parameters<typeof MDXProvider>[0]["components"];

const MDXComponents: Components = {
h1: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
<h1 className="mb-6 text-2xl text-gray-600 dark:text-gray-400" {...props} />
),
h2: (props) => (
h2: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
<h2
className="mb-2 mt-6 text-xl text-gray-600 dark:text-gray-400"
{...props}
/>
),
h3: (props) => (
h3: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
<h3
className="mb-2 mt-6 text-xl text-gray-600 dark:text-gray-400"
{...props}
/>
),
h4: (props) => (
h4: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
<h4
className="mb-2 mt-6 text-xl text-gray-600 dark:text-gray-400"
{...props}
/>
),
p: (props) => <p className="mb-4" {...props} />,
ul: (props) => <ul className="mb-8 list-inside list-disc" {...props} />,
ol: (props) => <ol className="mb-8 list-inside list-decimal" {...props} />,
blockquote: (props) => (
p: (props: React.HTMLAttributes<HTMLParagraphElement>) => (
<p className="mb-4" {...props} />
),
ul: (props: React.HTMLAttributes<HTMLUListElement>) => (
<ul className="mb-8 list-inside list-disc" {...props} />
),
ol: (props: React.HTMLAttributes<HTMLOListElement>) => (
<ol className="mb-8 list-inside list-decimal" {...props} />
),
blockquote: (props: React.BlockquoteHTMLAttributes<HTMLQuoteElement>) => (
<blockquote
className="my-4 border-l italic opacity-70 pl-4 text-gray-600 dark:text-gray-400"
{...props}
Expand Down

0 comments on commit 33528f1

Please sign in to comment.