|
1 | | -declare module 'astro:content' { |
2 | | - interface Render { |
3 | | - '.mdoc': Promise<{ |
4 | | - Content(props: Record<string, any>): import('astro').MarkdownInstance<{}>['Content']; |
5 | | - headings: import('astro').MarkdownHeading[]; |
6 | | - }>; |
7 | | - } |
8 | | -} |
9 | | - |
10 | | -declare module 'astro:content' { |
11 | | - interface Render { |
12 | | - '.mdx': Promise<{ |
13 | | - Content: import('astro').MarkdownInstance<{}>['Content']; |
14 | | - headings: import('astro').MarkdownHeading[]; |
15 | | - remarkPluginFrontmatter: Record<string, any>; |
16 | | - components: import('astro').MDXInstance<{}>['components']; |
17 | | - }>; |
18 | | - } |
19 | | -} |
20 | | - |
21 | | -declare module 'astro:content' { |
22 | | - interface RenderResult { |
23 | | - Content: import('astro/runtime/server/index.js').AstroComponentFactory; |
24 | | - headings: import('astro').MarkdownHeading[]; |
25 | | - remarkPluginFrontmatter: Record<string, any>; |
26 | | - } |
27 | | - interface Render { |
28 | | - '.md': Promise<RenderResult>; |
29 | | - } |
30 | | - |
31 | | - export interface RenderedContent { |
32 | | - html: string; |
33 | | - metadata?: { |
34 | | - imagePaths: Array<string>; |
35 | | - [key: string]: unknown; |
36 | | - }; |
37 | | - } |
38 | | -} |
39 | | - |
40 | | -declare module 'astro:content' { |
41 | | - type Flatten<T> = T extends { [K: string]: infer U } ? U : never; |
42 | | - |
43 | | - export type CollectionKey = keyof AnyEntryMap; |
44 | | - export type CollectionEntry<C extends CollectionKey> = Flatten<AnyEntryMap[C]>; |
45 | | - |
46 | | - export type ContentCollectionKey = keyof ContentEntryMap; |
47 | | - export type DataCollectionKey = keyof DataEntryMap; |
48 | | - |
49 | | - type AllValuesOf<T> = T extends any ? T[keyof T] : never; |
50 | | - type ValidContentEntrySlug<C extends keyof ContentEntryMap> = AllValuesOf< |
51 | | - ContentEntryMap[C] |
52 | | - >['slug']; |
53 | | - |
54 | | - /** @deprecated Use `getEntry` instead. */ |
55 | | - export function getEntryBySlug< |
56 | | - C extends keyof ContentEntryMap, |
57 | | - E extends ValidContentEntrySlug<C> | (string & {}), |
58 | | - >( |
59 | | - collection: C, |
60 | | - // Note that this has to accept a regular string too, for SSR |
61 | | - entrySlug: E, |
62 | | - ): E extends ValidContentEntrySlug<C> |
63 | | - ? Promise<CollectionEntry<C>> |
64 | | - : Promise<CollectionEntry<C> | undefined>; |
65 | | - |
66 | | - /** @deprecated Use `getEntry` instead. */ |
67 | | - export function getDataEntryById<C extends keyof DataEntryMap, E extends keyof DataEntryMap[C]>( |
68 | | - collection: C, |
69 | | - entryId: E, |
70 | | - ): Promise<CollectionEntry<C>>; |
71 | | - |
72 | | - export function getCollection<C extends keyof AnyEntryMap, E extends CollectionEntry<C>>( |
73 | | - collection: C, |
74 | | - filter?: (entry: CollectionEntry<C>) => entry is E, |
75 | | - ): Promise<E[]>; |
76 | | - export function getCollection<C extends keyof AnyEntryMap>( |
77 | | - collection: C, |
78 | | - filter?: (entry: CollectionEntry<C>) => unknown, |
79 | | - ): Promise<CollectionEntry<C>[]>; |
80 | | - |
81 | | - export function getEntry< |
82 | | - C extends keyof ContentEntryMap, |
83 | | - E extends ValidContentEntrySlug<C> | (string & {}), |
84 | | - >(entry: { |
85 | | - collection: C; |
86 | | - slug: E; |
87 | | - }): E extends ValidContentEntrySlug<C> |
88 | | - ? Promise<CollectionEntry<C>> |
89 | | - : Promise<CollectionEntry<C> | undefined>; |
90 | | - export function getEntry< |
91 | | - C extends keyof DataEntryMap, |
92 | | - E extends keyof DataEntryMap[C] | (string & {}), |
93 | | - >(entry: { |
94 | | - collection: C; |
95 | | - id: E; |
96 | | - }): E extends keyof DataEntryMap[C] |
97 | | - ? Promise<DataEntryMap[C][E]> |
98 | | - : Promise<CollectionEntry<C> | undefined>; |
99 | | - export function getEntry< |
100 | | - C extends keyof ContentEntryMap, |
101 | | - E extends ValidContentEntrySlug<C> | (string & {}), |
102 | | - >( |
103 | | - collection: C, |
104 | | - slug: E, |
105 | | - ): E extends ValidContentEntrySlug<C> |
106 | | - ? Promise<CollectionEntry<C>> |
107 | | - : Promise<CollectionEntry<C> | undefined>; |
108 | | - export function getEntry< |
109 | | - C extends keyof DataEntryMap, |
110 | | - E extends keyof DataEntryMap[C] | (string & {}), |
111 | | - >( |
112 | | - collection: C, |
113 | | - id: E, |
114 | | - ): E extends keyof DataEntryMap[C] |
115 | | - ? Promise<DataEntryMap[C][E]> |
116 | | - : Promise<CollectionEntry<C> | undefined>; |
117 | | - |
118 | | - /** Resolve an array of entry references from the same collection */ |
119 | | - export function getEntries<C extends keyof ContentEntryMap>( |
120 | | - entries: { |
121 | | - collection: C; |
122 | | - slug: ValidContentEntrySlug<C>; |
123 | | - }[], |
124 | | - ): Promise<CollectionEntry<C>[]>; |
125 | | - export function getEntries<C extends keyof DataEntryMap>( |
126 | | - entries: { |
127 | | - collection: C; |
128 | | - id: keyof DataEntryMap[C]; |
129 | | - }[], |
130 | | - ): Promise<CollectionEntry<C>[]>; |
131 | | - |
132 | | - export function render<C extends keyof AnyEntryMap>( |
133 | | - entry: AnyEntryMap[C][string], |
134 | | - ): Promise<RenderResult>; |
135 | | - |
136 | | - export function reference<C extends keyof AnyEntryMap>( |
137 | | - collection: C, |
138 | | - ): import('astro/zod').ZodEffects< |
139 | | - import('astro/zod').ZodString, |
140 | | - C extends keyof ContentEntryMap |
141 | | - ? { |
142 | | - collection: C; |
143 | | - slug: ValidContentEntrySlug<C>; |
144 | | - } |
145 | | - : { |
146 | | - collection: C; |
147 | | - id: keyof DataEntryMap[C]; |
148 | | - } |
149 | | - >; |
150 | | - // Allow generic `string` to avoid excessive type errors in the config |
151 | | - // if `dev` is not running to update as you edit. |
152 | | - // Invalid collection names will be caught at build time. |
153 | | - export function reference<C extends string>( |
154 | | - collection: C, |
155 | | - ): import('astro/zod').ZodEffects<import('astro/zod').ZodString, never>; |
156 | | - |
157 | | - type ReturnTypeOrOriginal<T> = T extends (...args: any[]) => infer R ? R : T; |
158 | | - type InferEntrySchema<C extends keyof AnyEntryMap> = import('astro/zod').infer< |
159 | | - ReturnTypeOrOriginal<Required<ContentConfig['collections'][C]>['schema']> |
160 | | - >; |
161 | | - |
162 | | - type ContentEntryMap = { |
163 | | - "docs": { |
164 | | -"01-welcome.md": { |
165 | | - id: "01-welcome.md"; |
166 | | - slug: "01-welcome"; |
167 | | - body: string; |
168 | | - collection: "docs"; |
169 | | - data: InferEntrySchema<"docs"> |
170 | | -} & { render(): Render[".md"] }; |
171 | | -"02-install-server-sdk.md": { |
172 | | - id: "02-install-server-sdk.md"; |
173 | | - slug: "02-install-server-sdk"; |
174 | | - body: string; |
175 | | - collection: "docs"; |
176 | | - data: InferEntrySchema<"docs"> |
177 | | -} & { render(): Render[".md"] }; |
178 | | -"03-initialize-client.md": { |
179 | | - id: "03-initialize-client.md"; |
180 | | - slug: "03-initialize-client"; |
181 | | - body: string; |
182 | | - collection: "docs"; |
183 | | - data: InferEntrySchema<"docs"> |
184 | | -} & { render(): Render[".md"] }; |
185 | | -"04-send-sms-code.md": { |
186 | | - id: "04-send-sms-code.md"; |
187 | | - slug: "04-send-sms-code"; |
188 | | - body: string; |
189 | | - collection: "docs"; |
190 | | - data: InferEntrySchema<"docs"> |
191 | | -} & { render(): Render[".md"] }; |
192 | | -"05-run-code.md": { |
193 | | - id: "05-run-code.md"; |
194 | | - slug: "05-run-code"; |
195 | | - body: string; |
196 | | - collection: "docs"; |
197 | | - data: InferEntrySchema<"docs"> |
198 | | -} & { render(): Render[".md"] }; |
199 | | -"06-whats-next.md": { |
200 | | - id: "06-whats-next.md"; |
201 | | - slug: "06-whats-next"; |
202 | | - body: string; |
203 | | - collection: "docs"; |
204 | | - data: InferEntrySchema<"docs"> |
205 | | -} & { render(): Render[".md"] }; |
206 | | -"index.mdx": { |
207 | | - id: "index.mdx"; |
208 | | - slug: "index"; |
209 | | - body: string; |
210 | | - collection: "docs"; |
211 | | - data: InferEntrySchema<"docs"> |
212 | | -} & { render(): Render[".mdx"] }; |
213 | | -}; |
214 | | - |
215 | | - }; |
216 | | - |
217 | | - type DataEntryMap = { |
218 | | - |
219 | | - }; |
220 | | - |
221 | | - type AnyEntryMap = ContentEntryMap & DataEntryMap; |
222 | | - |
223 | | - export type ContentConfig = typeof import("../../src/content/config.js"); |
224 | | -} |
0 commit comments