File tree Expand file tree Collapse file tree 11 files changed +67
-14
lines changed
Expand file tree Collapse file tree 11 files changed +67
-14
lines changed Original file line number Diff line number Diff line change 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+ )
Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ import { client } from '@/sanity/lib/client'
44import { token } from '@/sanity/lib/token'
55import { dev } from '@/lib/env'
66import { 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
910export async function fetchSanity < T = any > ( {
1011 query,
Original file line number Diff line number Diff 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 } ,
Original file line number Diff line number Diff 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 ] ,
Original file line number Diff line number Diff 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 } ) ,
Original file line number Diff line number Diff 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 : {
Original file line number Diff line number Diff 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 } ) ,
Original file line number Diff line number Diff 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 } ,
Original file line number Diff line number Diff 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 ( {
Original file line number Diff line number Diff line change 11import { structureTool } from 'sanity/structure'
2- import { singleton , group , directory } from 'sanitypress-utils '
2+ import { singleton , group , directory } from './lib/builders '
33import { VscFiles , VscServerProcess } from 'react-icons/vsc'
44
55export const structure = structureTool ( {
You can’t perform that action at this time.
0 commit comments