Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help: Preview #119

Open
paul-vd opened this issue Nov 17, 2020 · 1 comment
Open

help: Preview #119

paul-vd opened this issue Nov 17, 2020 · 1 comment
Assignees

Comments

@paul-vd
Copy link

paul-vd commented Nov 17, 2020

I'm not sure how to change the default "preview" I browsed the libraries types but can't see any reference to preview when defining a new document?

I suppose this is how it should be implemented?

import { defineDocument } from 'sanity-typed-queries';

const { document } = defineDocument('user', {
  name: {
    type: 'string',
  },
  email: {
    type: 'string',
    validation: (Rule) => Rule.required(),
  },
  handle: {
    type: 'slug',
    options: {
      source: 'name',
      maxLength: 96,
    },
  },
  avatar: {
    type: 'image',
    options: {
      hotspot: true,
      sources: [Default, Webcam],
    },
  },
  company: {
    type: 'string',
  },
});

export default {
  ...document,
  preview: {
    select: {
      title: 'name',
      media: 'image',
    },
  },
};
@danielroe
Copy link
Owner

Yes, exactly. I'd welcome a PR to take a third argument of additional 'options' if you think that would improve DX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants