Skip to content

Custom Preview Component #3607

Sep 7, 2022 · 3 comments · 2 replies
Discussion options

You must be logged in to vote

Hi all, I got this to work with the code below. It looks like the fields given in preview.select are passed to the function you specify in preview.prepare. preview.prepare should return on object with the fields you need, the elements in which are accessible to the component you give to components.preview as direct children of props (not props.value).

// File: schemas/bodyContent/bodyComponents/callout.ts

import { defineType, defineField } from 'sanity'
import { blockPreview } from 'sanity-pills'
import { GoInfo } from 'react-icons/go'
import { Card, Text } from '@sanity/ui'

const CalloutPreview = (props: any) => {
  // Check the console to see!
  console.log(props)
  return (
    <Card…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@alexbchr
Comment options

@mattjoc-braze
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by bjoerge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants