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