@@ -45,6 +45,10 @@ declare module 'astro:content' {
4545 collection : C ;
4646 slug : E ;
4747 } ;
48+ export type ReferenceLiveEntry < C extends keyof LiveContentConfig [ 'collections' ] > = {
49+ collection : C ;
50+ id : string ;
51+ } ;
4852
4953 /** @deprecated Use `getEntry` instead. */
5054 export function getEntryBySlug <
@@ -73,6 +77,13 @@ declare module 'astro:content' {
7377 filter ?: ( entry : CollectionEntry < C > ) => unknown ,
7478 ) : Promise < CollectionEntry < C > [ ] > ;
7579
80+ export function getLiveCollection < C extends keyof LiveContentConfig [ 'collections' ] > (
81+ collection : C ,
82+ filter ?: LiveLoaderCollectionFilterType < C > ,
83+ ) : Promise <
84+ import ( 'astro' ) . LiveDataCollectionResult < LiveLoaderDataType < C > , LiveLoaderErrorType < C > >
85+ > ;
86+
7687 export function getEntry <
7788 C extends keyof ContentEntryMap ,
7889 E extends ValidContentEntrySlug < C > | ( string & { } ) ,
@@ -109,6 +120,10 @@ declare module 'astro:content' {
109120 ? Promise < DataEntryMap [ C ] [ E ] > | undefined
110121 : Promise < DataEntryMap [ C ] [ E ] >
111122 : Promise < CollectionEntry < C > | undefined > ;
123+ export function getLiveEntry < C extends keyof LiveContentConfig [ 'collections' ] > (
124+ collection : C ,
125+ filter : string | LiveLoaderEntryFilterType < C > ,
126+ ) : Promise < import ( 'astro' ) . LiveDataEntryResult < LiveLoaderDataType < C > , LiveLoaderErrorType < C > > > ;
112127
113128 /** Resolve an array of entry references from the same collection */
114129 export function getEntries < C extends keyof ContentEntryMap > (
@@ -162,5 +177,33 @@ declare module 'astro:content' {
162177
163178 type AnyEntryMap = ContentEntryMap & DataEntryMap ;
164179
180+ type ExtractLoaderTypes < T > = T extends import ( 'astro/loaders' ) . LiveLoader <
181+ infer TData ,
182+ infer TEntryFilter ,
183+ infer TCollectionFilter ,
184+ infer TError
185+ >
186+ ? { data : TData ; entryFilter : TEntryFilter ; collectionFilter : TCollectionFilter ; error : TError }
187+ : { data : never ; entryFilter : never ; collectionFilter : never ; error : never } ;
188+ type ExtractDataType < T > = ExtractLoaderTypes < T > [ 'data' ] ;
189+ type ExtractEntryFilterType < T > = ExtractLoaderTypes < T > [ 'entryFilter' ] ;
190+ type ExtractCollectionFilterType < T > = ExtractLoaderTypes < T > [ 'collectionFilter' ] ;
191+ type ExtractErrorType < T > = ExtractLoaderTypes < T > [ 'error' ] ;
192+
193+ type LiveLoaderDataType < C extends keyof LiveContentConfig [ 'collections' ] > =
194+ LiveContentConfig [ 'collections' ] [ C ] [ 'schema' ] extends undefined
195+ ? ExtractDataType < LiveContentConfig [ 'collections' ] [ C ] [ 'loader' ] >
196+ : import ( 'astro/zod' ) . infer <
197+ Exclude < LiveContentConfig [ 'collections' ] [ C ] [ 'schema' ] , undefined >
198+ > ;
199+ type LiveLoaderEntryFilterType < C extends keyof LiveContentConfig [ 'collections' ] > =
200+ ExtractEntryFilterType < LiveContentConfig [ 'collections' ] [ C ] [ 'loader' ] > ;
201+ type LiveLoaderCollectionFilterType < C extends keyof LiveContentConfig [ 'collections' ] > =
202+ ExtractCollectionFilterType < LiveContentConfig [ 'collections' ] [ C ] [ 'loader' ] > ;
203+ type LiveLoaderErrorType < C extends keyof LiveContentConfig [ 'collections' ] > = ExtractErrorType <
204+ LiveContentConfig [ 'collections' ] [ C ] [ 'loader' ]
205+ > ;
206+
165207 export type ContentConfig = typeof import ( "../src/content/config.js" ) ;
208+ export type LiveContentConfig = never ;
166209}
0 commit comments