nuxt-modules / sanity

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

fix: enable stega only when visual editing is enabled #1023

Closed rdunk closed 1 week ago

rdunk commented 1 week ago

As raised in https://github.com/nuxt-modules/sanity/issues/1007, I believe @jesperbjerke is correct in his assumption that stega should be disabled (and CSM should not be delivered) if visual editing is disabled. Looks like an oversight on my part.

This PR just adds some additional checks, chiefly to modify the client config and set stega: false if visual editing is not enabled.

netlify[bot] commented 1 week ago

Deploy Preview for nuxt-sanity-module canceled.

Name Link
Latest commit 8066b1f1f30bd23909741257433e77aec2e9ab3f
Latest deploy log https://app.netlify.com/sites/nuxt-sanity-module/deploys/6686bc414b089c0008da8f3f
jesperbjerke commented 1 week ago

Nice @rdunk! Sort of related (sorry for potentially derailing this PR); I think there might be some optimisations to be done in general around the visual editing setup. Looks to me like all the dependencies for visual editing is loaded no matter if you're actually currently in visual editing mode. This will cause a unnecessary performance hit for regular visitors (and SEO) because they have to load additional resources.

An awesome setup would have been to be able to use the minimal client for all regular traffic, and as soon as the preview mode has been enabled (which Studio does by opening the presentation tool), we'd then load the needed resources.

rdunk commented 1 week ago

Hey @jesperbjerke, would you be able to create a new issue for that? The module that handles rendering overlays and all its associated dependencies should be lazy loaded when enableVisualEditing is called. If you could give me more details in an issue that would be helpful, thanks!