'use client'
import { useState } from 'react'
import Image from 'next/image'
import Link from 'next/link'
import { cn } from '@/lib/utils'
import type {
UnorderedListProps,
OrderedListProps,
EmphasizedTextProps,
ItalicTextProps,
StrongTextProps,
BoldTextProps,
DeletedTextProps,
UnderlinedTextProps,
HorizontalRuleProps,
BlockquoteProps,
AnchorLinkProps,
HeadingProps,
ImgProps,
ParagraphProps
} from './types'
import { PARAGRAPH_SIZES } from '../Paragraph/constants'
const filterProps = (props: object) => {
const newProps = { ...props }
if ('node' in newProps) {
delete newProps.node
}
return newProps
}
const UnorderedList = ({ className, ...props }: UnorderedListProps) => (
)
const OrderedList = ({ className, ...props }: OrderedListProps) => (
)
const Paragraph = ({ className, ...props }: ParagraphProps) => (
)
const EmphasizedText = ({ className, ...props }: EmphasizedTextProps) => (
)
const ItalicText = ({ className, ...props }: ItalicTextProps) => (
)
const StrongText = ({ className, ...props }: StrongTextProps) => (
)
const BoldText = ({ className, ...props }: BoldTextProps) => (
)
const UnderlinedText = ({ className, ...props }: UnderlinedTextProps) => (
)
const DeletedText = ({ className, ...props }: DeletedTextProps) => (
)
const HorizontalRule = ({ className, ...props }: HorizontalRuleProps) => (
)
const Blockquote = ({ className, ...props }: BlockquoteProps) => (
)
const AnchorLink = ({ className, ...props }: AnchorLinkProps) => (
)
const Heading1 = ({ className, ...props }: HeadingProps) => (
)
const Heading2 = ({ className, ...props }: HeadingProps) => (
)
const Heading3 = ({ className, ...props }: HeadingProps) => (
)
const Heading4 = ({ className, ...props }: HeadingProps) => (
)
const Heading5 = ({ className, ...props }: HeadingProps) => (
)
const Heading6 = ({ className, ...props }: HeadingProps) => (
)
const Img = ({ src, alt }: ImgProps) => {
const [error, setError] = useState(false)
if (!src) return null
return (
{error ? (
Image unavailable
{typeof src === 'string' ? src : 'Invalid source'}
) : (
setError(true)}
unoptimized
/>
)}
)
}
export const inlineComponents = {
h1: Heading1,
h2: Heading2,
h3: Heading3,
h4: Heading4,
h5: Heading5,
h6: Heading6,
ul: UnorderedList,
ol: OrderedList,
em: EmphasizedText,
i: ItalicText,
strong: StrongText,
b: BoldText,
u: UnderlinedText,
del: DeletedText,
hr: HorizontalRule,
blockquote: Blockquote,
a: AnchorLink,
img: Img,
p: Paragraph
}