Skip to content

Commit 9db2f4e

Browse files
committed
fix type errors
1 parent 9810285 commit 9db2f4e

File tree

11 files changed

+67
-14
lines changed

11 files changed

+67
-14
lines changed

src/sanity/lib/builders.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import type {
2+
StructureBuilder,
3+
ListItemBuilder,
4+
ListItem,
5+
Divider,
6+
} from 'sanity/structure'
7+
8+
export const singleton = (
9+
S: StructureBuilder,
10+
id: string,
11+
title?: string,
12+
): ListItemBuilder =>
13+
S.listItem()
14+
.id(id)
15+
.title(
16+
title ||
17+
id
18+
.split(/(?=[A-Z])/)
19+
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
20+
.join(' '),
21+
)
22+
.child(S.editor().id(id).schemaType(id).documentId(id))
23+
24+
export const group = (
25+
S: StructureBuilder,
26+
title: string,
27+
items: (ListItemBuilder | ListItem | Divider)[],
28+
): ListItemBuilder =>
29+
S.listItem().title(title).child(S.list().title(title).items(items))
30+
31+
export const directory = (
32+
S: StructureBuilder,
33+
path: string,
34+
{ maxLevel }: { maxLevel?: number } = {},
35+
) =>
36+
S.listItem()
37+
.title(`/${path}`)
38+
.schemaType('page')
39+
.child(
40+
S.documentList()
41+
.id(`page.${path.replaceAll('/', '-')}`)
42+
.filter(
43+
`
44+
string::startsWith(metadata.slug.current, $path)
45+
${maxLevel !== undefined ? `&& count(string::split(metadata.slug.current, '/')) <= ${maxLevel + 1}` : ''}
46+
`,
47+
)
48+
.params({ path: path + '/' }),
49+
)

src/sanity/lib/fetch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { client } from '@/sanity/lib/client'
44
import { token } from '@/sanity/lib/token'
55
import { dev } from '@/lib/env'
66
import { draftMode } from 'next/headers'
7-
import { defineLive, type QueryOptions, type QueryParams } from 'next-sanity'
7+
import { defineLive } from 'next-sanity/live'
8+
import { type QueryOptions, type QueryParams } from 'next-sanity'
89

910
export async function fetchSanity<T = any>({
1011
query,

src/sanity/schemaTypes/modules/creative/image.creative.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default defineArrayMember({
2828
{ title: '3:2', value: '1.5' },
2929
{ title: '4:3', value: '4 / 3' },
3030
]}
31-
{...props}
31+
{...(props as any)}
3232
/>
3333
),
3434
},

src/sanity/schemaTypes/modules/creative/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ export default defineType({
8686
group: 'options',
8787
}),
8888
defineField({
89-
...alignItems,
89+
...(alignItems as any),
9090
fieldset: 'alignment',
9191
group: 'options',
9292
hidden: ({ parent }) => parent.bordered,
9393
}),
9494
defineField({
95-
...textAlign,
95+
...(textAlign as any),
9696
fieldset: 'alignment',
9797
}),
9898
],

src/sanity/schemaTypes/modules/hero.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ export default defineType({
5252
group: 'asset',
5353
}),
5454
defineField({
55-
...alignItems,
55+
...(alignItems as any),
5656
fieldset: 'alignment',
5757
group: 'options',
5858
}),
5959
defineField({
60-
...textAlign,
60+
...(textAlign as any),
6161
fieldset: 'alignment',
6262
group: 'options',
6363
}),

src/sanity/schemaTypes/modules/stat-list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default defineType({
6767
],
6868
group: 'content',
6969
}),
70-
defineField(textAlign),
70+
defineField(textAlign as any),
7171
],
7272
preview: {
7373
select: {

src/sanity/schemaTypes/objects/icon.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default defineType({
4747
<TextInputWithPresets
4848
prefix="ic0n.dev/"
4949
presets={ic0nPresets}
50-
{...props}
50+
{...(props as any)}
5151
/>
5252
),
5353
},
@@ -59,7 +59,7 @@ export default defineType({
5959
initialValue: sizePresets[0],
6060
components: {
6161
input: (props) => (
62-
<TextInputWithPresets presets={sizePresets} {...props} />
62+
<TextInputWithPresets presets={sizePresets} {...(props as any)} />
6363
),
6464
},
6565
}),

src/sanity/schemaTypes/objects/img.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default defineType({
5454
<TextInputWithPresets
5555
prefix="@media"
5656
presets={presets}
57-
{...props}
57+
{...(props as any)}
5858
/>
5959
),
6060
},

src/sanity/schemaTypes/objects/metadata.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default defineType({
2323
validation: (Rule) => Rule.max(60).warning(),
2424
components: {
2525
input: (props) => (
26-
<CharacterCount max={60} {...props}>
26+
<CharacterCount max={60} {...(props as any)}>
2727
<PreviewOG title={props.elementProps.value} />
2828
</CharacterCount>
2929
),
@@ -34,7 +34,9 @@ export default defineType({
3434
type: 'text',
3535
validation: (Rule) => Rule.max(160).warning(),
3636
components: {
37-
input: (props) => <CharacterCount as="textarea" max={160} {...props} />,
37+
input: (props) => (
38+
<CharacterCount as="textarea" max={160} {...(props as any)} />
39+
),
3840
},
3941
}),
4042
defineField({

src/sanity/structure.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { structureTool } from 'sanity/structure'
2-
import { singleton, group, directory } from 'sanitypress-utils'
2+
import { singleton, group, directory } from './lib/builders'
33
import { VscFiles, VscServerProcess } from 'react-icons/vsc'
44

55
export const structure = structureTool({

0 commit comments

Comments
 (0)