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

Cannot get the plugin working #56

Open
andyjamesn opened this issue May 27, 2024 · 1 comment
Open

Cannot get the plugin working #56

andyjamesn opened this issue May 27, 2024 · 1 comment

Comments

@andyjamesn
Copy link

andyjamesn commented May 27, 2024

I am starting with a fresh Sanity studio install with blank setup.

These are the steps I followed

  1. install @tinloof/sanity-studio and add it to my config
 plugins: [structureTool(), visionTool(), pages({
    creatablePages: ["page"],
    previewUrl: {
      previewMode: {
        enable: "/api/draft",
      },
    },
  }),
  ],
  1. Setup a page schema and add definepathName and import it in schema index.js
import {defineField, defineType} from 'sanity'
import { definePathname } from "@tinloof/sanity-studio";

export const page = defineType({
  name: 'page',
  title: 'Page',
  type: 'document',
  fields: [
    defineField({
      name: 'name',
      type: 'string',
    }),
    definePathname({
        name: "pathname",
      }),
  ],
})

That is pretty much it.

But when I try and load it, I am getting a strange result

First I get this warning
CleanShot 2024-05-27 at 15 28 24@2x

If I click continue anyway, it seems to load studio inside itself

CleanShot 2024-05-27 at 15 28 35@2x

What am I missing?

@Jamiewarb
Copy link
Contributor

Jamiewarb commented May 30, 2024

This issue is unrelated to this plugin (this plugin wraps the presentation tool from Sanity, and what you're seeing is only the presentation tool).

Your issues happens when you don't have a frontend with visual preview running at the URL you've given the presentation tool, so it can't connect to it.

Do you have an endpoint in your app for /api/draft? This should be returning a URL to redirect the user to. That URL should take the user to the correct page on your website, where you should have visual editing set up. If this is a Next app, you can view a guide on this here: https://www.sanity.io/guides/nextjs-app-router-live-preview

If that isn't enough to solve your issue, I'd encourage you to look at documentation for Sanity Presentation and Visual Editing, or post for help in the Sanity Slack channel.

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