-
Notifications
You must be signed in to change notification settings - Fork 0
/
structure.ts
32 lines (30 loc) · 1023 Bytes
/
structure.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import Iframe from 'sanity-plugin-iframe-pane';
import type { DefaultDocumentNodeResolver } from 'sanity/desk';
export const getDefaultDocumentNode: DefaultDocumentNodeResolver = (
S,
{ schemaType }
) => {
if (schemaType === 'project') {
return S.document().views([
S.view.form(),
S.view
.component(Iframe)
.options({
// Required: Accepts an async function
url: `${
process.env.NEXT_PUBLIC_VERCEL_URL || 'http://localhost:3000'
}/api/preview`,
// Optional: Set the default size
defaultSize: `desktop`, // default `desktop`
// Optional: Add a reload button, or reload on new document revisions
reload: {
button: true, // default `undefined`
},
// Optional: Pass attributes to the underlying `iframe` element:
// See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
attributes: {},
})
.title('Preview'),
]);
}
};