Skip to content

Change content schemas to require alt text with an image #188

Open
@outofambit

Description

@outofambit

In our content schemas, it is possible to provide an featured image but no alt text for it. Our schemas hold them separately as in:

featuredImage: image().optional(),
featuredImageAlt: z.string().optional(),

a schema like this would prevent authors from adding an image without also including alt text:

featuredImage: z.object({
    src: image(),
    alt: z.string()
}).optional(),

which also makes it possible to provide a default with accurate alt text, as in:

featuredImage: z.object({
    src: image(),
    alt: z.string()
}).optional().default({
  src: PlaceholderImage
  alt: 'the p5 logo in a grey box'
}),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions