-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsanity.config.ts
63 lines (59 loc) · 1.65 KB
/
sanity.config.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { codeInput } from '@sanity/code-input'
import { documentInternationalization } from '@sanity/document-internationalization'
import { visionTool } from '@sanity/vision'
import { defineConfig, SanityDocument } from 'sanity'
import { Iframe, IframeOptions } from 'sanity-plugin-iframe-pane'
import { DefaultDocumentNodeResolver, deskTool } from 'sanity/desk'
import { apiVersion, dataset, projectId } from '~/lib/sanity.api'
import { schema } from '~/schemas'
const url = {
origin: 'same-origin',
preview: (doc: SanityDocument) =>
doc?.slug?.['current']
? `/${doc._type}/${doc.slug['current']}`
: new Error('Missing slug'),
draftMode: '/api/draft',
}
export const defaultDocumentNode: DefaultDocumentNodeResolver = (
S,
{ schemaType },
) => {
switch (schemaType) {
case `post`:
return S.document().views([
S.view.form(),
S.view
.component(Iframe)
.options({
url,
reload: { button: true },
} satisfies IframeOptions)
.title('Preview'),
])
default:
return S.document().views([S.view.form()])
}
}
export default defineConfig({
basePath: '/studio',
name: 'kir-dev-blog-v3',
title: 'Kir-Dev Blog v3',
projectId,
dataset,
schema,
plugins: [
deskTool({
defaultDocumentNode,
}),
visionTool({ defaultApiVersion: apiVersion }),
codeInput(),
documentInternationalization({
// Required configuration
supportedLanguages: [
{ id: 'hu', title: 'Hungarian' },
{ id: 'en', title: 'English' },
],
schemaTypes: ['siteSection', 'techStack'], // todo: project, post, course
}),
],
})