πŸ‘€ See Sanity in action: Watch product demo now β†’

How would you structure something like this in the backend? It's part of an article, so there might be other types of formatting in the column, and images can be either left...

1 replies
Last updated: Jan 7, 2021
How would you structure something like this in the backend? It's part of an article, so there might be other types of formatting in the column, and images can be either left or right.
Jan 7, 2021, 11:01 AM
export default {
  name: 'textWithIllustration',
  type: 'object',
  title: 'Text with Illustation',
  fields: [
    {
      name: 'heading',
      type: 'string',
      title: 'Heading'
    },
    {
      name: 'text',
      type: 'richText', // or text, or simpleRichText depending on what you want to allow,
      title: 'Text'
    },
    {
      name: 'illustration',
      type: 'figure', // image field with alt and caption fields
      title: 'Illustration'
    }
    /*
        {
            name: 'alternate',
            type: 'boolean',
            title: 'Use alternative position'
        },
        */
  ]
}
I'd do something like this and let the frontend design system decide the formatting for what's best in terms of composition and alteration. If you do want editorial control you can add that as an agnostic option, or be more specific with a predefined string field for direction or such.
Jan 7, 2021, 11:14 AM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Categorized in