2024-02-24 13:56:35 +00:00
|
|
|
import { PortableText } from "@portabletext/react";
|
2024-02-24 17:36:12 +00:00
|
|
|
import { client } from "@/sanity/lib/client";
|
|
|
|
import imageUrlBuilder from "@sanity/image-url";
|
|
|
|
import Link from "next/link";
|
|
|
|
import ImageViewer from "@/components/articles/ImageViewer";
|
2024-02-24 09:33:35 +00:00
|
|
|
|
2024-02-24 13:56:35 +00:00
|
|
|
export default function PostContent({ content }: { content: any }) {
|
2024-02-24 17:36:12 +00:00
|
|
|
const imageBuilder = imageUrlBuilder(client);
|
|
|
|
|
|
|
|
const componentSet = {
|
|
|
|
types: {
|
|
|
|
image: ({ value }: any) => {
|
|
|
|
const image = imageBuilder.image(value);
|
|
|
|
return <ImageViewer src={image.url()} alt={value.alt} />;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
marks: {
|
|
|
|
link: ({ children, value }: any) => {
|
|
|
|
const rel = !value.href.startsWith("/") ? "noreferrer noopener" : undefined;
|
|
|
|
return (
|
|
|
|
<Link href={value.href} rel={rel}>
|
|
|
|
{children}
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return <PortableText value={content} components={componentSet} />;
|
2024-02-24 13:56:35 +00:00
|
|
|
}
|