File size: 1,073 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 38 39 40 41 42 43 44 45 46 |
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(),
}),
],
});
|