mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
This PR updates the `cms-sanity` example to use: - App Router - TypeScript - Sanity Studio v3 instead of v2 - Embeds the Studio inside the next app on the `/studio` route. - ISR / Data Cache (revalidations through `revalidatePath` while in Live Visual Editing, time-based to match the Sanity API CDN in production). - Support Vercel Visual Editing out of the box. - The new `next-sanity/image` component. - Vercel Speed Insights. - The Sanity Presentation Tool for live content previews. - Sanity Portable Text setup to fully support `@tailwindcss/typography`. - [AI Assist](https://www.sanity.io/docs/ai-assist) - Auto fill in `alt` text on images. - Preset prompts for content creation
32 lines
763 B
TypeScript
32 lines
763 B
TypeScript
import { Image } from "next-sanity/image";
|
|
|
|
import { urlForImage } from "@/sanity/lib/utils";
|
|
|
|
interface CoverImageProps {
|
|
image: any;
|
|
priority?: boolean;
|
|
}
|
|
|
|
export default function CoverImage(props: CoverImageProps) {
|
|
const { image: source, priority } = props;
|
|
const image = source?.asset?._ref ? (
|
|
<Image
|
|
className="h-auto w-full"
|
|
width={2000}
|
|
height={1000}
|
|
alt={source?.alt || ""}
|
|
src={urlForImage(source)?.height(1000).width(2000).url() as string}
|
|
sizes="100vw"
|
|
priority={priority}
|
|
/>
|
|
) : (
|
|
<div className="bg-slate-50" style={{ paddingTop: "50%" }} />
|
|
);
|
|
|
|
return (
|
|
<div className="shadow-md transition-shadow duration-200 group-hover:shadow-lg sm:mx-0">
|
|
{image}
|
|
</div>
|
|
);
|
|
}
|