Skip to content

Commit 2bdc352

Browse files
feature: make post's coverImage not required in schema and confirm frontend doesnt rely on an image (#165)
1 parent ed4ced2 commit 2bdc352

File tree

4 files changed

+290
-614
lines changed

4 files changed

+290
-614
lines changed

frontend/sanity.types.ts

Lines changed: 60 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@
1313
*/
1414

1515
// Source: schema.json
16-
export type CallToAction = {
17-
_type: 'callToAction'
18-
heading: string
19-
text?: string
20-
buttonText?: string
21-
link?: Link
22-
}
23-
2416
export type Link = {
2517
_type: 'link'
2618
linkType?: 'href' | 'page' | 'post'
@@ -40,42 +32,19 @@ export type Link = {
4032
openInNewTab?: boolean
4133
}
4234

35+
export type CallToAction = {
36+
_type: 'callToAction'
37+
heading: string
38+
text?: string
39+
buttonText?: string
40+
link?: Link
41+
}
42+
4343
export type InfoSection = {
4444
_type: 'infoSection'
4545
heading?: string
4646
subheading?: string
47-
content?: Array<{
48-
children?: Array<{
49-
marks?: Array<string>
50-
text?: string
51-
_type: 'span'
52-
_key: string
53-
}>
54-
style?: 'normal' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'blockquote'
55-
listItem?: 'bullet' | 'number'
56-
markDefs?: Array<{
57-
linkType?: 'href' | 'page' | 'post'
58-
href?: string
59-
page?: {
60-
_ref: string
61-
_type: 'reference'
62-
_weak?: boolean
63-
[internalGroqTypeReferenceTo]?: 'page'
64-
}
65-
post?: {
66-
_ref: string
67-
_type: 'reference'
68-
_weak?: boolean
69-
[internalGroqTypeReferenceTo]?: 'post'
70-
}
71-
openInNewTab?: boolean
72-
_type: 'link'
73-
_key: string
74-
}>
75-
level?: number
76-
_type: 'block'
77-
_key: string
78-
}>
47+
content?: BlockContent
7948
}
8049

8150
export type BlockContent = Array<{
@@ -166,6 +135,22 @@ export type Settings = {
166135
}
167136
}
168137

138+
export type SanityImageCrop = {
139+
_type: 'sanity.imageCrop'
140+
top: number
141+
bottom: number
142+
left: number
143+
right: number
144+
}
145+
146+
export type SanityImageHotspot = {
147+
_type: 'sanity.imageHotspot'
148+
x: number
149+
y: number
150+
height: number
151+
width: number
152+
}
153+
169154
export type Page = {
170155
_id: string
171156
_type: 'page'
@@ -196,7 +181,7 @@ export type Post = {
196181
slug: Slug
197182
content?: BlockContent
198183
excerpt?: string
199-
coverImage: {
184+
coverImage?: {
200185
asset?: {
201186
_ref: string
202187
_type: 'reference'
@@ -241,6 +226,12 @@ export type Person = {
241226
}
242227
}
243228

229+
export type Slug = {
230+
_type: 'slug'
231+
current: string
232+
source?: string
233+
}
234+
244235
export type SanityAssistInstructionTask = {
245236
_type: 'sanity.assist.instructionTask'
246237
path?: string
@@ -397,25 +388,20 @@ export type SanityImagePalette = {
397388

398389
export type SanityImageDimensions = {
399390
_type: 'sanity.imageDimensions'
400-
height?: number
401-
width?: number
402-
aspectRatio?: number
403-
}
404-
405-
export type SanityImageHotspot = {
406-
_type: 'sanity.imageHotspot'
407-
x?: number
408-
y?: number
409-
height?: number
410-
width?: number
391+
height: number
392+
width: number
393+
aspectRatio: number
411394
}
412395

413-
export type SanityImageCrop = {
414-
_type: 'sanity.imageCrop'
415-
top?: number
416-
bottom?: number
417-
left?: number
418-
right?: number
396+
export type SanityImageMetadata = {
397+
_type: 'sanity.imageMetadata'
398+
location?: Geopoint
399+
dimensions?: SanityImageDimensions
400+
palette?: SanityImagePalette
401+
lqip?: string
402+
blurHash?: string
403+
hasAlpha?: boolean
404+
isOpaque?: boolean
419405
}
420406

421407
export type SanityFileAsset = {
@@ -440,6 +426,13 @@ export type SanityFileAsset = {
440426
source?: SanityAssetSourceData
441427
}
442428

429+
export type SanityAssetSourceData = {
430+
_type: 'sanity.assetSourceData'
431+
name?: string
432+
id?: string
433+
url?: string
434+
}
435+
443436
export type SanityImageAsset = {
444437
_id: string
445438
_type: 'sanity.imageAsset'
@@ -463,46 +456,25 @@ export type SanityImageAsset = {
463456
source?: SanityAssetSourceData
464457
}
465458

466-
export type SanityImageMetadata = {
467-
_type: 'sanity.imageMetadata'
468-
location?: Geopoint
469-
dimensions?: SanityImageDimensions
470-
palette?: SanityImagePalette
471-
lqip?: string
472-
blurHash?: string
473-
hasAlpha?: boolean
474-
isOpaque?: boolean
475-
}
476-
477459
export type Geopoint = {
478460
_type: 'geopoint'
479461
lat?: number
480462
lng?: number
481463
alt?: number
482464
}
483465

484-
export type Slug = {
485-
_type: 'slug'
486-
current: string
487-
source?: string
488-
}
489-
490-
export type SanityAssetSourceData = {
491-
_type: 'sanity.assetSourceData'
492-
name?: string
493-
id?: string
494-
url?: string
495-
}
496-
497466
export type AllSanitySchemaTypes =
498-
| CallToAction
499467
| Link
468+
| CallToAction
500469
| InfoSection
501470
| BlockContent
502471
| Settings
472+
| SanityImageCrop
473+
| SanityImageHotspot
503474
| Page
504475
| Post
505476
| Person
477+
| Slug
506478
| SanityAssistInstructionTask
507479
| SanityAssistTaskStatus
508480
| SanityAssistSchemaTypeAnnotations
@@ -518,14 +490,11 @@ export type AllSanitySchemaTypes =
518490
| SanityImagePaletteSwatch
519491
| SanityImagePalette
520492
| SanityImageDimensions
521-
| SanityImageHotspot
522-
| SanityImageCrop
493+
| SanityImageMetadata
523494
| SanityFileAsset
495+
| SanityAssetSourceData
524496
| SanityImageAsset
525-
| SanityImageMetadata
526497
| Geopoint
527-
| Slug
528-
| SanityAssetSourceData
529498
export declare const internalGroqTypeReferenceTo: unique symbol
530499
// Source: ./sanity/lib/queries.ts
531500
// Variable: settingsQuery
@@ -673,7 +642,7 @@ export type AllPostsQueryResult = Array<{
673642
crop?: SanityImageCrop
674643
alt?: string
675644
_type: 'image'
676-
}
645+
} | null
677646
date: string
678647
author: {
679648
firstName: string
@@ -713,7 +682,7 @@ export type MorePostsQueryResult = Array<{
713682
crop?: SanityImageCrop
714683
alt?: string
715684
_type: 'image'
716-
}
685+
} | null
717686
date: string
718687
author: {
719688
firstName: string
@@ -775,7 +744,7 @@ export type PostQueryResult = {
775744
crop?: SanityImageCrop
776745
alt?: string
777746
_type: 'image'
778-
}
747+
} | null
779748
date: string
780749
author: {
781750
firstName: string

0 commit comments

Comments
 (0)