🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Issue with custom preview component not showing in search results view

3 replies
Last updated: Jul 29, 2021
Hello you clever people. Got a bit of a conundrum here. I have created a custom preview component for my main doc type, and managed to have this preview show up as the default view, so when I select a word in the menu I see the nicely formatted preview, as in fig 1. However if I use the search bar and find a word (as illustrated in fig 2) and select it by clicking or hitting enter I get this different view showing the form, and with the links to the view options (Display, Editor) removed. How can I make the document show in the custom preview in this "searched result"-view?
Jul 29, 2021, 2:13 PM
My deskstructure might be relevant:
import { CgBox as ByCatIcon } from 'react-icons/cg';
import S from '@sanity/desk-tool/structure-builder';
import WordPreview from '../cpt/WordPreview';

export default () =>
        .title('Words by category')
          // List out the categories
            .title('Words by category')
            // When a category is selected, pass its id down to the next pane
            .child((categoryId) =>
              // load a new document list
                // Use a GROQ filter to get documents.
                // This filter checks for sampleProjects that has the
                // categoryId in its array of references
                .filter('_type == "word" && $categoryId == category._ref')
                .params({ categoryId })
        .title('All words')
        // When you open this list item, list out the documents
        // of the type category"

export const getDefaultDocumentNode = ({ schemaType }) => {
  // Conditionally return a different configuration based on the schema type
  if (schemaType === 'word') {
    return S.document().views([
Jul 29, 2021, 2:58 PM
Jul 29, 2021, 4:24 PM
Joining the effort, then.
Jul 29, 2021, 4:27 PM

Sanity– build remarkable experiences at scale

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

Was this answer helpful?