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

feat: support visual editing #949

Merged
merged 15 commits into from
Mar 6, 2024
Merged

feat: support visual editing #949

merged 15 commits into from
Mar 6, 2024

Conversation

rdunk
Copy link
Collaborator

@rdunk rdunk commented Jan 5, 2024

This PR provides a method for implementing Sanity visual editing in Nuxt applications.

Current Progress

  • Support visual editing using useSanityQuery and CSM
  • Support "basic" visual editing using useAsyncData and client.fetch
  • Update playground
  • Update tests
  • Update documentation

Copy link

netlify bot commented Jan 5, 2024

Deploy Preview for nuxt-sanity-module ready!

Name Link
🔨 Latest commit 85a654f
🔍 Latest deploy log https://app.netlify.com/sites/nuxt-sanity-module/deploys/65e8bbbefeab54000855ca11
😎 Deploy Preview https://deploy-preview-949--nuxt-sanity-module.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@rdunk
Copy link
Collaborator Author

rdunk commented Jan 25, 2024

Looks like the type tests are failing, the generated RuntimeConfig and PublicRuntimeConfig override those declared in index.d.ts.

Potentially relevant issue: nuxt/nuxt#20379

@rdunk rdunk force-pushed the feat/visual-editing branch 2 times, most recently from f45d1fe to 428b94a Compare February 2, 2024 16:41
@rdunk rdunk marked this pull request as ready for review February 2, 2024 16:45
@rdunk rdunk requested a review from danielroe February 2, 2024 16:46
Copy link
Collaborator

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is great! Thank you so much for the phenomenal work here.

Sorry to have just pushed changes - mostly a result of my lack of time.

If you have a chance to review, would you see if I've unwittingly undone something you set for a good reason? 🙏

@blowsie
Copy link

blowsie commented Feb 22, 2024

refs #934

@rdunk
Copy link
Collaborator Author

rdunk commented Mar 5, 2024

Think this is good to go pending documentation.

Copy link

nuxt-studio bot commented Mar 6, 2024

Live Preview ready!

Name Edit Preview Latest Commit
Sanity Edit on Studio ↗︎ View Live Preview 85a654f

@rdunk
Copy link
Collaborator Author

rdunk commented Mar 6, 2024

Some minimal docs are up, I figured best to get this shipped and adjust and improve those accordingly. Let me know if you'd like them structured differently. Also snuck in a few last minute changes to the configuration based on some internal conversations. Ready for a final review!

(Can I leave merge/release up to you @danielroe?)

@danielroe
Copy link
Collaborator

Perfect!

@danielroe danielroe merged commit aeb9d11 into main Mar 6, 2024
5 checks passed
@danielroe danielroe deleted the feat/visual-editing branch March 6, 2024 20:09
@timbenniks
Copy link

Hey all, I'm super excited about this feature, when will there be a release to NPM in which I can use visual editing?

@danielroe
Copy link
Collaborator

There's a beta release at @nuxtjs/sanity@beta you can try out. There's currently a few niggles with Vite + the newer sanity dependencies that will require us to handle optimizeDeps (probably?)

@timbenniks
Copy link

You are correct. I just had a look with beta 1.9.0 but I can't get it to run.

I have this in my Nuxt config:

vite: {
  optimizeDeps: { exclude: ["parse-headers"] }
},

Screenshot 2024-03-09 at 22 31 33

@danielroe
Copy link
Collaborator

You probably need to include it. But you will find a rabbit hole down there. If you get a chance and get something working, do let me know. One main issue is that in order for optimising deps with shamefully-hoist=false, they have to be explicitly installed. (And these are sub deps of sub deps which makes it a real pain.)

One avenue to explore is that this is not an issue in the module repository which suggests that something about the config (maybe another package being installed?) avoids the issue. But I need to make some time to investigate.

@timbenniks
Copy link

The deeper I dive, the weirder it gets!

Screenshot 2024-03-10 at 11 33 23

I try this to see if i can get any further: https://www.sanity.io/docs/nuxt-loader

@rdunk
Copy link
Collaborator Author

rdunk commented Mar 10, 2024

@timbenniks Best not to go down the @sanity/nuxt-loader path! We will be deprecating that package in favour of this module as soon as we have a stable release.

@danielroe
Copy link
Collaborator

Released! Please do let me know if you encounter any niggles. 🙏

@timbenniks
Copy link

Hey all, using "@nuxtjs/sanity": "^1.10.1" I still get similar issues as described above.
Screenshot 2024-03-30 at 12 30 44

@blowsie
Copy link

blowsie commented Mar 31, 2024

Hey all, using "@nuxtjs/sanity": "^1.10.1" I still get similar issues as described above. Screenshot 2024-03-30 at 12 30 44

Im not familiar with the issue you are encountering, but this may help you get started
https://github.com/sanity-io/sanity-template-nuxt-clean

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

Successfully merging this pull request may close these issues.

None yet

4 participants