Skip to content
This repository was archived by the owner on Nov 19, 2025. It is now read-only.

Commit 2d4a910

Browse files
committed
feat: add image
1 parent cfebbd2 commit 2d4a910

File tree

17 files changed

+764
-330
lines changed

17 files changed

+764
-330
lines changed

apps/cms/sanity.types.ts

Lines changed: 107 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,6 @@ export type SanityImageDimensions = {
3939
aspectRatio?: number;
4040
};
4141

42-
export type SanityImageHotspot = {
43-
_type: "sanity.imageHotspot";
44-
x?: number;
45-
y?: number;
46-
height?: number;
47-
width?: number;
48-
};
49-
50-
export type SanityImageCrop = {
51-
_type: "sanity.imageCrop";
52-
top?: number;
53-
bottom?: number;
54-
left?: number;
55-
right?: number;
56-
};
57-
5842
export type SanityFileAsset = {
5943
_id: string;
6044
_type: "sanity.fileAsset";
@@ -77,6 +61,67 @@ export type SanityFileAsset = {
7761
source?: SanityAssetSourceData;
7862
};
7963

64+
export type Geopoint = {
65+
_type: "geopoint";
66+
lat?: number;
67+
lng?: number;
68+
alt?: number;
69+
};
70+
71+
export type PageBuilder = Array<{
72+
_key: string;
73+
} & Hero | {
74+
_key: string;
75+
} & Heading>;
76+
77+
export type Link = {
78+
_type: "link";
79+
children?: string;
80+
type?: "href" | "page" | "post";
81+
href?: string;
82+
page?: {
83+
_ref: string;
84+
_type: "reference";
85+
_weak?: boolean;
86+
[internalGroqTypeReferenceTo]?: "page";
87+
};
88+
post?: {
89+
_ref: string;
90+
_type: "reference";
91+
_weak?: boolean;
92+
[internalGroqTypeReferenceTo]?: "post";
93+
};
94+
};
95+
96+
export type ImageWithAlt = {
97+
_type: "imageWithAlt";
98+
asset?: {
99+
_ref: string;
100+
_type: "reference";
101+
_weak?: boolean;
102+
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
103+
};
104+
hotspot?: SanityImageHotspot;
105+
crop?: SanityImageCrop;
106+
alt?: string;
107+
};
108+
109+
export type SanityImageCrop = {
110+
_type: "sanity.imageCrop";
111+
top?: number;
112+
bottom?: number;
113+
left?: number;
114+
right?: number;
115+
};
116+
117+
export type SanityImageHotspot = {
118+
_type: "sanity.imageHotspot";
119+
x?: number;
120+
y?: number;
121+
height?: number;
122+
width?: number;
123+
};
124+
80125
export type SanityImageAsset = {
81126
_id: string;
82127
_type: "sanity.imageAsset";
@@ -100,6 +145,13 @@ export type SanityImageAsset = {
100145
source?: SanityAssetSourceData;
101146
};
102147

148+
export type SanityAssetSourceData = {
149+
_type: "sanity.assetSourceData";
150+
name?: string;
151+
id?: string;
152+
url?: string;
153+
};
154+
103155
export type SanityImageMetadata = {
104156
_type: "sanity.imageMetadata";
105157
location?: Geopoint;
@@ -111,50 +163,36 @@ export type SanityImageMetadata = {
111163
isOpaque?: boolean;
112164
};
113165

114-
export type Geopoint = {
115-
_type: "geopoint";
116-
lat?: number;
117-
lng?: number;
118-
alt?: number;
119-
};
120-
121-
export type SanityAssetSourceData = {
122-
_type: "sanity.assetSourceData";
123-
name?: string;
124-
id?: string;
125-
url?: string;
166+
export type Hero = {
167+
_type: "hero";
168+
title: string;
169+
description: string;
170+
link: LinkRequired;
171+
image: {
172+
asset: {
173+
_ref: string;
174+
_type: "reference";
175+
_weak?: boolean;
176+
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
177+
};
178+
hotspot?: SanityImageHotspot;
179+
crop?: SanityImageCrop;
180+
alt?: string;
181+
_type: "imageWithAltRequired";
182+
};
126183
};
127184

128-
export type PageBuilder = Array<{
129-
_key: string;
130-
} & Hero | {
131-
_key: string;
132-
} & Heading>;
133-
134-
export type Link = {
135-
_type: "link";
136-
children?: string;
137-
type?: "href" | "page" | "post";
138-
href?: string;
139-
page?: {
140-
_ref: string;
141-
_type: "reference";
142-
_weak?: boolean;
143-
[internalGroqTypeReferenceTo]?: "page";
144-
};
145-
post?: {
185+
export type ImageWithAltRequired = {
186+
_type: "imageWithAltRequired";
187+
asset?: {
146188
_ref: string;
147189
_type: "reference";
148190
_weak?: boolean;
149-
[internalGroqTypeReferenceTo]?: "post";
191+
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
150192
};
151-
};
152-
153-
export type Hero = {
154-
_type: "hero";
155-
title: string;
156-
description: string;
157-
link: LinkRequired;
193+
hotspot?: SanityImageHotspot;
194+
crop?: SanityImageCrop;
195+
alt?: string;
158196
};
159197

160198
export type LinkRequired = {
@@ -395,11 +433,11 @@ export type SanityAssistSchemaTypeField = {
395433
} & SanityAssistInstruction>;
396434
};
397435

398-
export type AllSanitySchemaTypes = SanityImagePaletteSwatch | SanityImagePalette | SanityImageDimensions | SanityImageHotspot | SanityImageCrop | SanityFileAsset | SanityImageAsset | SanityImageMetadata | Geopoint | SanityAssetSourceData | PageBuilder | Link | Hero | LinkRequired | Heading | Content | Post | Person | Page | Seo | Slug | Settings | SanityAssistInstructionTask | SanityAssistTaskStatus | SanityAssistSchemaTypeAnnotations | SanityAssistOutputType | SanityAssistOutputField | SanityAssistInstructionContext | AssistInstructionContext | SanityAssistInstructionUserInput | SanityAssistInstructionPrompt | SanityAssistInstructionFieldRef | SanityAssistInstruction | SanityAssistSchemaTypeField;
436+
export type AllSanitySchemaTypes = SanityImagePaletteSwatch | SanityImagePalette | SanityImageDimensions | SanityFileAsset | Geopoint | PageBuilder | Link | ImageWithAlt | SanityImageCrop | SanityImageHotspot | SanityImageAsset | SanityAssetSourceData | SanityImageMetadata | Hero | ImageWithAltRequired | LinkRequired | Heading | Content | Post | Person | Page | Seo | Slug | Settings | SanityAssistInstructionTask | SanityAssistTaskStatus | SanityAssistSchemaTypeAnnotations | SanityAssistOutputType | SanityAssistOutputField | SanityAssistInstructionContext | AssistInstructionContext | SanityAssistInstructionUserInput | SanityAssistInstructionPrompt | SanityAssistInstructionFieldRef | SanityAssistInstruction | SanityAssistSchemaTypeField;
399437
export declare const internalGroqTypeReferenceTo: unique symbol;
400438
// Source: ./src/queries/get-page-query.ts
401439
// Variable: getPageQuery
402-
// Query: *[_type == 'page' && slug.current == $slug][0] { _id, _type, title, pageBuilder[] { _type, _key, _type == "hero" => { title, description, link { children, "href": coalesce( select( type == "page" => "/" + page->slug.current, type == "post" => "/posts/" + post->slug.current, href ), "" )},}, _type == "heading" => { heading,},}, }
440+
// Query: *[_type == 'page' && slug.current == $slug][0] { _id, _type, title, pageBuilder[] { _type, _key, _type == "hero" => { title, description, link { children, "href": coalesce( select( type == "page" => "/" + page->slug.current, type == "post" => "/posts/" + post->slug.current, href ), "" )}, image,}, _type == "heading" => { heading,},}, }
403441
export type GetPageQueryResult = {
404442
_id: string;
405443
_type: "page";
@@ -417,6 +455,18 @@ export type GetPageQueryResult = {
417455
children: string;
418456
href: string | "";
419457
};
458+
image: {
459+
asset: {
460+
_ref: string;
461+
_type: "reference";
462+
_weak?: boolean;
463+
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
464+
};
465+
hotspot?: SanityImageHotspot;
466+
crop?: SanityImageCrop;
467+
alt?: string;
468+
_type: "imageWithAltRequired";
469+
};
420470
}>;
421471
} | null;
422472

@@ -463,7 +513,7 @@ export type GetPostQueryResult = {
463513
import "@sanity/client";
464514
declare module "@sanity/client" {
465515
interface SanityQueries {
466-
"\n *[_type == 'page' && slug.current == $slug][0] {\n _id,\n _type,\n title,\n pageBuilder[] {\n _type,\n _key,\n _type == \"hero\" => {\n title,\n description,\n link {\n children,\n \"href\": coalesce(\n select(\n type == \"page\" => \"/\" + page->slug.current,\n type == \"post\" => \"/posts/\" + post->slug.current,\n href\n ),\n \"\"\n )\n},\n},\n _type == \"heading\" => {\n heading,\n},\n},\n }\n": GetPageQueryResult;
516+
"\n *[_type == 'page' && slug.current == $slug][0] {\n _id,\n _type,\n title,\n pageBuilder[] {\n _type,\n _key,\n _type == \"hero\" => {\n title,\n description,\n link {\n children,\n \"href\": coalesce(\n select(\n type == \"page\" => \"/\" + page->slug.current,\n type == \"post\" => \"/posts/\" + post->slug.current,\n href\n ),\n \"\"\n )\n},\n image,\n},\n _type == \"heading\" => {\n heading,\n},\n},\n }\n": GetPageQueryResult;
467517
"\n *[_type == 'post' && slug.current == $slug][0] {\n title,\n content[] {\n ...,\n markDefs[] {\n ...,\n _type == \"link\" => {\n children,\n \"href\": coalesce(\n select(\n type == \"page\" => \"/\" + page->slug.current,\n type == \"post\" => \"/posts/\" + post->slug.current,\n href\n ),\n \"\"\n )\n},\n }\n},\n }\n": GetPostQueryResult;
468518
}
469519
}

0 commit comments

Comments
 (0)