mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Adds support for the [newly introduced Sanity TypeGen](https://www.sanity.io/blog/introducing-sanity-typegen)! 🥳
37 lines
942 B
TypeScript
37 lines
942 B
TypeScript
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>
|
|
);
|
|
}
|