Files
Cody OlsenandGitHub 41019c2314 Update Sanity example for App Router (#63045)
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
2024-03-10 19:49:18 -07:00

50 lines
1.1 KiB
TypeScript

/**
* This component uses Portable Text to render a post body.
*
* You can learn more about Portable Text on:
* https://www.sanity.io/docs/block-content
* https://github.com/portabletext/react-portabletext
* https://portabletext.org/
*
*/
import {
PortableText,
type PortableTextComponents,
type PortableTextBlock,
} from "next-sanity";
export default function CustomPortableText({
className,
value,
}: {
className?: string;
value: PortableTextBlock[];
}) {
const components: PortableTextComponents = {
block: {
h5: ({ children }) => (
<h5 className="mb-2 text-sm font-semibold">{children}</h5>
),
h6: ({ children }) => (
<h6 className="mb-1 text-xs font-semibold">{children}</h6>
),
},
marks: {
link: ({ children, value }) => {
return (
<a href={value?.href} rel="noreferrer noopener">
{children}
</a>
);
},
},
};
return (
<div className={["prose", className].filter(Boolean).join(" ")}>
<PortableText components={components} value={value} />
</div>
);
}