import Image from "next/image";
import type { PortableTextComponents } from "@portabletext/react";
import { urlFor } from "@/lib/sanityImage";
function extractYouTubeId(url: string): string | null {
const match = url.match(
/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,
);
return match?.[1] ?? null;
}
export const portableTextComponents: PortableTextComponents = {
types: {
image: ({ value }) => {
if (!value?.asset) return null;
const src = urlFor(value).url();
return (