File size: 1,119 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
/**
* This component uses Portable Text to render a post body.
*
* You can learn more about Portable Text on:
* https://www.sanity.io/docs/block-content
* https://github.com/portabletext/react-portabletext
* https://portabletext.org/
*
*/
import {
PortableText,
type PortableTextComponents,
type PortableTextBlock,
} from "next-sanity";
export default function CustomPortableText({
className,
value,
}: {
className?: string;
value: PortableTextBlock[];
}) {
const components: PortableTextComponents = {
block: {
h5: ({ children }) => (
<h5 className="mb-2 text-sm font-semibold">{children}</h5>
),
h6: ({ children }) => (
<h6 className="mb-1 text-xs font-semibold">{children}</h6>
),
},
marks: {
link: ({ children, value }) => {
return (
<a href={value?.href} rel="noreferrer noopener">
{children}
</a>
);
},
},
};
return (
<div className={["prose", className].filter(Boolean).join(" ")}>
<PortableText components={components} value={value} />
</div>
);
}
|