nuxt-modules / sanity

Sanity integration for Nuxt
https://sanity.nuxtjs.org
MIT License
215 stars 33 forks source link

No difference between Draft and Published mode in the Presentation? #1034

Closed notflip closed 3 weeks ago

notflip commented 1 month ago

The visual editing setup works perfectly, with my setup below.

However, I noticed that when I select "Draft" or "Published" in the studio, it doesn't make a difference to the presentation. If I add a word or two to a text field, and not publish it. Changing between Draft and Published does not change this.

Screenshot 2024-07-24 at 14 51 45

This is my full code for the visual editing

nuxt.config.ts

  sanity: {
    projectId: process.env.NUXT_SANITY_PROJECT_ID,
    dataset: process.env.NUXT_SANITY_DATASET,
    useCdn: false,
    apiVersion: process.env.NUXT_SANITY_API_VERSION || '2024-03-15',
    visualEditing: {
      studioUrl: process.env.NUXT_SANITY_STUDIO_URL || 'http://localhost:3333',
      token: process.env.NUXT_SANITY_TOKEN,
      stega: true,
    },
  },

sanity.config.ts

    presentationTool({
      resolve: {
        // Document resolver, so that the presentation tools know which document to show when we navigate in it.
        mainDocuments: defineDocuments([
          // Singleton
          {
            route: '/',
            type: 'homePage',
          },
          // GROQ
          {
            route: '/:slug',
            filter: `_type == "page" && slug.current == $slug`,
          },
        ]),
        locations: {
          // Provide a notice when a document is used across all pages
          companyInfo: defineLocations({
            message: 'Deze informatie wordt op elke pagina weergegeven',
          }),
        },
      },

      previewUrl: {
        // make sure that the origin is the the `preview` branch URL
        origin: process.env.SANITY_STUDIO_PREVIEW_URL,
        previewMode: {
          enable: '/preview/enable',
          disable: '/preview/disable',
        },
      },
    }),
rdunk commented 1 month ago

If you currently have a document open in the document pane, the values shown in your app will reflect the latest draft version of that document. Is that the behaviour you're seeing?

In other words, if you close the document, do you still see no difference when switching between Draft and Published?

notflip commented 1 month ago

You're right, When the pane is closed, and I switch between draft and published, I do see the difference.