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

Commit 91c65c4

Browse files
committed
feat: add portable text and link
1 parent 3755db8 commit 91c65c4

File tree

22 files changed

+997
-12
lines changed

22 files changed

+997
-12
lines changed

apps/cms/sanity.types.ts

Lines changed: 106 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,76 @@ export type SanityAssetSourceData = {
125125
url?: string;
126126
};
127127

128+
export type LinkRequired = {
129+
_type: "linkRequired";
130+
children: string;
131+
type: "href" | "page" | "post";
132+
href?: string;
133+
page?: {
134+
_ref: string;
135+
_type: "reference";
136+
_weak?: boolean;
137+
[internalGroqTypeReferenceTo]?: "page";
138+
};
139+
post?: {
140+
_ref: string;
141+
_type: "reference";
142+
_weak?: boolean;
143+
[internalGroqTypeReferenceTo]?: "post";
144+
};
145+
};
146+
147+
export type Link = {
148+
_type: "link";
149+
children?: string;
150+
type?: "href" | "page" | "post";
151+
href?: string;
152+
page?: {
153+
_ref: string;
154+
_type: "reference";
155+
_weak?: boolean;
156+
[internalGroqTypeReferenceTo]?: "page";
157+
};
158+
post?: {
159+
_ref: string;
160+
_type: "reference";
161+
_weak?: boolean;
162+
[internalGroqTypeReferenceTo]?: "post";
163+
};
164+
};
165+
166+
export type Content = Array<{
167+
children?: Array<{
168+
marks?: Array<string>;
169+
text?: string;
170+
_type: "span";
171+
_key: string;
172+
}>;
173+
style?: "normal" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "blockquote";
174+
listItem?: "bullet" | "number";
175+
markDefs?: Array<{
176+
type: "href" | "page" | "post";
177+
href?: string;
178+
page?: {
179+
_ref: string;
180+
_type: "reference";
181+
_weak?: boolean;
182+
[internalGroqTypeReferenceTo]?: "page";
183+
};
184+
post?: {
185+
_ref: string;
186+
_type: "reference";
187+
_weak?: boolean;
188+
[internalGroqTypeReferenceTo]?: "post";
189+
};
190+
_type: "link";
191+
_key: string;
192+
}>;
193+
level?: number;
194+
_type: "block";
195+
_key: string;
196+
}>;
197+
128198
export type Post = {
129199
_id: string;
130200
_type: "post";
@@ -139,6 +209,7 @@ export type Post = {
139209
_weak?: boolean;
140210
[internalGroqTypeReferenceTo]?: "person";
141211
};
212+
content: Content;
142213
seo: Seo;
143214
};
144215

@@ -305,7 +376,7 @@ export type SanityAssistSchemaTypeField = {
305376
} & SanityAssistInstruction>;
306377
};
307378

308-
export type AllSanitySchemaTypes = SanityImagePaletteSwatch | SanityImagePalette | SanityImageDimensions | SanityImageHotspot | SanityImageCrop | SanityFileAsset | SanityImageAsset | SanityImageMetadata | Geopoint | SanityAssetSourceData | Post | Person | Page | Seo | Slug | Settings | SanityAssistInstructionTask | SanityAssistTaskStatus | SanityAssistSchemaTypeAnnotations | SanityAssistOutputType | SanityAssistOutputField | SanityAssistInstructionContext | AssistInstructionContext | SanityAssistInstructionUserInput | SanityAssistInstructionPrompt | SanityAssistInstructionFieldRef | SanityAssistInstruction | SanityAssistSchemaTypeField;
379+
export type AllSanitySchemaTypes = SanityImagePaletteSwatch | SanityImagePalette | SanityImageDimensions | SanityImageHotspot | SanityImageCrop | SanityFileAsset | SanityImageAsset | SanityImageMetadata | Geopoint | SanityAssetSourceData | LinkRequired | Link | Content | Post | Person | Page | Seo | Slug | Settings | SanityAssistInstructionTask | SanityAssistTaskStatus | SanityAssistSchemaTypeAnnotations | SanityAssistOutputType | SanityAssistOutputField | SanityAssistInstructionContext | AssistInstructionContext | SanityAssistInstructionUserInput | SanityAssistInstructionPrompt | SanityAssistInstructionFieldRef | SanityAssistInstruction | SanityAssistSchemaTypeField;
309380
export declare const internalGroqTypeReferenceTo: unique symbol;
310381
// Source: ./src/queries/get-page-query.ts
311382
// Variable: getPageQuery
@@ -316,16 +387,48 @@ export type GetPageQueryResult = {
316387

317388
// Source: ./src/queries/get-post-query.ts
318389
// Variable: getPostQuery
319-
// Query: *[_type == 'post' && slug.current == $slug][0] { title, }
390+
// Query: *[_type == 'post' && slug.current == $slug][0] { title, content[] { ..., markDefs[] { ..., _type == "link" => { children, "href": coalesce( select( type == "page" => "/" + page->slug.current, type == "post" => "/posts/" + post->slug.current, href ), "" )}, }}, }
320391
export type GetPostQueryResult = {
321392
title: string;
393+
content: Array<{
394+
children?: Array<{
395+
marks?: Array<string>;
396+
text?: string;
397+
_type: "span";
398+
_key: string;
399+
}>;
400+
style?: "blockquote" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "normal";
401+
listItem?: "bullet" | "number";
402+
markDefs: Array<{
403+
type: "href" | "page" | "post";
404+
href: string | "";
405+
page?: {
406+
_ref: string;
407+
_type: "reference";
408+
_weak?: boolean;
409+
[internalGroqTypeReferenceTo]?: "page";
410+
};
411+
post?: {
412+
_ref: string;
413+
_type: "reference";
414+
_weak?: boolean;
415+
[internalGroqTypeReferenceTo]?: "post";
416+
};
417+
_type: "link";
418+
_key: string;
419+
children: null;
420+
}> | null;
421+
level?: number;
422+
_type: "block";
423+
_key: string;
424+
}>;
322425
} | null;
323426

324427
// Query TypeMap
325428
import "@sanity/client";
326429
declare module "@sanity/client" {
327430
interface SanityQueries {
328431
"\n *[_type == 'page' && slug.current == $slug][0] {\n title,\n }\n": GetPageQueryResult;
329-
"\n *[_type == 'post' && slug.current == $slug][0] {\n title,\n }\n": GetPostQueryResult;
432+
"\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;
330433
}
331434
}

0 commit comments

Comments
 (0)