-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanity.config.ts
113 lines (104 loc) · 3.58 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import { visionTool } from '@sanity/vision'
import { defineConfig, isDev } from 'sanity'
import { deskTool } from 'sanity/desk'
import { dashboardTool, projectUsersWidget } from '@sanity/dashboard'
import { documentListWidget } from 'sanity-plugin-dashboard-widget-document-list'
import { netlifyWidget } from "sanity-plugin-dashboard-widget-netlify"
import { media } from 'sanity-plugin-media'
import { schemaTypes } from './schemas'
// TODO: change back to `sanity/presentation` when fix is released
import { presentationTool, DocumentLocationResolver } from '@sanity/presentation'
import { Observable, map } from 'rxjs'
import { deskStructure } from './deskStructure'
import { BrandLogo } from './components/brandLogo'
import { EnhancedNavbar } from './components/enhancedNavbar'
import { ngTheme } from './theme'
export const projectId = process.env.SANITY_STUDIO_PROJECT_ID!
export const dataset = process.env.SANITY_STUDIO_DATASET!
const locate: DocumentLocationResolver = (params, context) => {
const { documentStore } = context
if (params.type === 'post') {
// Listen to the query and fetch the draft and published document
const doc$ = documentStore.listenQuery(`*[_id == $id][0]{slug,title}`, params, {
perspective: 'previewDrafts',
}) as Observable<{
slug: { current: string | null } | null
title: string | null
} | null>
return doc$.pipe(
map((doc) => {
if (!doc || !doc.slug?.current) return null
return {
locations: [
{
title: doc.title || 'Untitled',
href: `/post/${doc.slug.current}`,
},
{
title: 'Posts',
href: `/`,
},
],
}
}),
)
}
return null
}
// Need the Vision tool available only in development (not in deployed studios)
const devOnlyPlugins = [ visionTool() ]
export default defineConfig({
name: 'ng-data-lake',
title: 'NG Sanity Studio',
projectId,
dataset,
plugins: [
deskTool({
structure: deskStructure,
}),
dashboardTool({
widgets: [
netlifyWidget({
title: 'Deploy changes to the Production Website (production)',
sites: [
{
title: "Click on DEPLOY to upload changes to nrityagram.org. When Deploy is a 'Success', click on 'View' to view the site",
apiId: 'abcdefgh-abcd-1234-1234-123456789012',
buildHookId: 'somecrazyalphanumeric',
name: 'nameofhook',
url: 'https://url-of-site-on-netlify'
}
],
layout: { width: 'medium', height: 'auto' }
}),
documentListWidget({
title: 'Last Published Content',
query: '*[_type in ["page", "homepage", "contactPage", "navigation"] && !(_id in path("drafts.**"))] | order(_updatedAt desc)[0..8]',
layout: { width: 'medium' }
}),
projectUsersWidget({ layout: { width: 'medium', height: 'auto' } }),
documentListWidget({
title: 'Last Edited Content (with unpublished changes)',
query: '*[_type in ["page", "homepage", "contactDetails", "navigation"] && (_id in path("drafts.**"))] | order(_updatedAt desc)',
layout: { width: 'medium' }
}),
]
}),
presentationTool({
previewUrl: process.env.SANITY_STUDIO_PREVIEW_URL || 'http://localhost:3000',
locate,
}),
media(),
...(isDev ? devOnlyPlugins : []),
],
schema: {
types: schemaTypes,
},
theme: ngTheme,
studio: {
components: {
logo: BrandLogo,
navbar: EnhancedNavbar,
},
},
})