When upgrading to latest version of the plugin (v3.1.1), my doc url no longer respects the getPreviewUrl inputs (slug url). Here is my code:
import { Iframe } from 'sanity-plugin-iframe-pane'
// Show the correct URL based on the current document
function getPreviewUrl(doc) {
return doc?.slug?.current
? `http://localhost:3000/projects/${doc.slug.current}`
: `${window.location.host}`
}
// Import this into the deskTool() plugin
export const defaultDocumentNode = (S, {schemaType}) => {
// Only show preview pane on `project` schema type documents
switch (schemaType) {
case `project`:
return S.document().views([
S.view.form(),
S.view
.component(Iframe)
.title('Preview')
.options({
url: (doc) => getPreviewUrl(doc) + '?preview=true',
})
.title('Preview')
])
default:
return S.document().views([S.view.form()])
}
}
This code returns the slug null3333?preview=true. When downgrading to v2.6.1, the slug is correctly rendered: http://localhost:3000/projects/my-project?preview=true.
The current solution is to downgrade plugin versions.
Expected behavior
The correct slug/url should display within the plugin config. Perhaps my code is incorrect? Seems odd since this is the same code structure I have used for the past year or more...
Describe the bug
When upgrading to latest version of the plugin (
v3.1.1
), my doc url no longer respects thegetPreviewUrl
inputs (slug url). Here is my code:This code returns the slug
null3333?preview=true
. When downgrading tov2.6.1
, the slug is correctly rendered:http://localhost:3000/projects/my-project?preview=true
.The current solution is to downgrade plugin versions.
Expected behavior
The correct slug/url should display within the plugin config. Perhaps my code is incorrect? Seems odd since this is the same code structure I have used for the past year or more...