File size: 942 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 |
import { Image } from "next-sanity/image";
import type { Author } from "@/sanity.types";
import { urlForImage } from "@/sanity/lib/utils";
interface Props {
name: string;
picture: Exclude<Author["picture"], undefined> | null;
}
export default function Avatar({ name, picture }: Props) {
return (
<div className="flex items-center text-xl">
{picture?.asset?._ref ? (
<div className="mr-4 h-12 w-12">
<Image
alt={picture?.alt || ""}
className="h-full rounded-full object-cover"
height={48}
width={48}
src={
urlForImage(picture)
?.height(96)
.width(96)
.fit("crop")
.url() as string
}
/>
</div>
) : (
<div className="mr-1">By </div>
)}
<div className="text-pretty text-xl font-bold">{name}</div>
</div>
);
}
|