mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
- Updates deps with minor bugfixes. - Fixes typos and removes debug console logs. - Less aggressive validation rules for alt text
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import { UserIcon } from "@sanity/icons";
|
|
import { defineField, defineType } from "sanity";
|
|
|
|
export default defineType({
|
|
name: "author",
|
|
title: "Author",
|
|
icon: UserIcon,
|
|
type: "document",
|
|
fields: [
|
|
defineField({
|
|
name: "name",
|
|
title: "Name",
|
|
type: "string",
|
|
validation: (rule) => rule.required(),
|
|
}),
|
|
defineField({
|
|
name: "picture",
|
|
title: "Picture",
|
|
type: "image",
|
|
fields: [
|
|
{
|
|
name: "alt",
|
|
type: "string",
|
|
title: "Alternative text",
|
|
description: "Important for SEO and accessiblity.",
|
|
validation: (rule) => {
|
|
return rule.custom((alt, context) => {
|
|
if ((context.document?.picture as any)?.asset?._ref && !alt) {
|
|
return "Required";
|
|
}
|
|
return true;
|
|
});
|
|
},
|
|
},
|
|
],
|
|
options: {
|
|
hotspot: true,
|
|
aiAssist: {
|
|
imageDescriptionField: "alt",
|
|
},
|
|
},
|
|
validation: (rule) => rule.required(),
|
|
}),
|
|
],
|
|
});
|