astro 5.9.3 → 5.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/client.d.ts +1 -3
  2. package/components/Image.astro +5 -6
  3. package/components/Picture.astro +5 -5
  4. package/components/ResponsivePicture.astro +1 -0
  5. package/dist/actions/integration.d.ts +2 -1
  6. package/dist/actions/integration.js +3 -2
  7. package/dist/actions/utils.d.ts +1 -1
  8. package/dist/actions/utils.js +9 -8
  9. package/dist/assets/internal.d.ts +1 -5
  10. package/dist/assets/internal.js +21 -23
  11. package/dist/assets/types.d.ts +4 -4
  12. package/dist/assets/vite-plugin-assets.js +2 -2
  13. package/dist/content/config.d.ts +74 -0
  14. package/dist/content/config.js +78 -0
  15. package/dist/content/consts.d.ts +1 -0
  16. package/dist/content/consts.js +2 -0
  17. package/dist/content/content-layer.js +3 -3
  18. package/dist/content/loaders/errors.d.ts +20 -0
  19. package/dist/content/loaders/errors.js +64 -0
  20. package/dist/content/loaders/types.d.ts +21 -0
  21. package/dist/content/runtime.d.ts +23 -7
  22. package/dist/content/runtime.js +218 -28
  23. package/dist/content/types-generator.js +11 -4
  24. package/dist/content/utils.d.ts +37 -1
  25. package/dist/content/utils.js +29 -8
  26. package/dist/content/vite-plugin-content-virtual-mod.d.ts +1 -1
  27. package/dist/content/vite-plugin-content-virtual-mod.js +20 -6
  28. package/dist/core/config/schemas/base.d.ts +44 -44
  29. package/dist/core/config/schemas/base.js +9 -9
  30. package/dist/core/config/schemas/refined.js +0 -7
  31. package/dist/core/config/schemas/relative.d.ts +58 -58
  32. package/dist/core/constants.js +1 -1
  33. package/dist/core/csp/config.d.ts +3 -3
  34. package/dist/core/csp/config.js +1 -0
  35. package/dist/core/dev/dev.js +1 -1
  36. package/dist/core/errors/errors-data.d.ts +16 -0
  37. package/dist/core/errors/errors-data.js +15 -4
  38. package/dist/core/errors/errors.js +1 -1
  39. package/dist/core/messages.js +2 -2
  40. package/dist/core/session.d.ts +1 -1
  41. package/dist/core/session.js +10 -9
  42. package/dist/integrations/hooks.js +5 -2
  43. package/dist/runtime/client/dev-toolbar/apps/astro.js +4 -6
  44. package/dist/runtime/server/render/csp.js +1 -1
  45. package/dist/types/public/config.d.ts +40 -131
  46. package/dist/types/public/content.d.ts +30 -0
  47. package/package.json +4 -3
  48. package/templates/content/module.mjs +14 -0
  49. package/templates/content/types.d.ts +43 -0
  50. package/types/content.d.ts +23 -80
@@ -123,7 +123,7 @@ interface BuiltinSessionConfig<TDriver extends keyof BuiltinDriverOptions> exten
123
123
  }
124
124
  interface CustomSessionConfig extends CommonSessionConfig {
125
125
  /** Entrypoint for a custom session driver */
126
- driver: string;
126
+ driver?: string;
127
127
  options?: Record<string, unknown>;
128
128
  }
129
129
  interface TestSessionConfig extends CommonSessionConfig {
@@ -1242,58 +1242,70 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
1242
1242
  remotePatterns?: Partial<RemotePattern>[];
1243
1243
  /**
1244
1244
  * @docs
1245
- * @name image.experimentalLayout
1245
+ * @name image.layout
1246
1246
  * @type {ImageLayout}
1247
1247
  * @default `undefined`
1248
+ * @version 5.10.0
1248
1249
  * @description
1249
1250
  * The default layout type for responsive images. Can be overridden by the `layout` prop on the image component.
1250
- * Requires the `experimental.responsiveImages` flag to be enabled.
1251
1251
  * - `constrained` - The image will scale to fit the container, maintaining its aspect ratio, but will not exceed the specified dimensions.
1252
1252
  * - `fixed` - The image will maintain its original dimensions.
1253
1253
  * - `full-width` - The image will scale to fit the container, maintaining its aspect ratio.
1254
+ *
1255
+ * See [the `layout` component property](https://docs.astro.build/en/reference/modules/astro-assets/#layout) for more details.
1254
1256
  */
1255
- experimentalLayout?: ImageLayout | undefined;
1257
+ layout?: ImageLayout | undefined;
1256
1258
  /**
1257
1259
  * @docs
1258
- * @name image.experimentalObjectFit
1260
+ * @name image.objectFit
1259
1261
  * @type {ImageFit}
1260
1262
  * @default `"cover"`
1263
+ * @version 5.10.0
1261
1264
  * @description
1262
1265
  * The default object-fit value for responsive images. Can be overridden by the `fit` prop on the image component.
1263
- * Requires the `experimental.responsiveImages` flag to be enabled.
1266
+ * Requires a value for `layout` to be set.
1267
+ *
1268
+ * See [the `fit` component property](https://docs.astro.build/en/reference/modules/astro-assets/#fit) for more details.
1264
1269
  */
1265
- experimentalObjectFit?: ImageFit;
1270
+ objectFit?: ImageFit;
1266
1271
  /**
1267
1272
  * @docs
1268
- * @name image.experimentalObjectPosition
1273
+ * @name image.objectPosition
1269
1274
  * @type {string}
1270
1275
  * @default `"center"`
1276
+ * @version 5.10.0
1271
1277
  * @description
1272
1278
  * The default object-position value for responsive images. Can be overridden by the `position` prop on the image component.
1273
- * Requires the `experimental.responsiveImages` flag to be enabled.
1279
+ * Requires a value for `layout` to be set.
1280
+ *
1281
+ * See [the `position` component property](https://docs.astro.build/en/reference/modules/astro-assets/#position) for more details.
1274
1282
  */
1275
- experimentalObjectPosition?: string;
1283
+ objectPosition?: string;
1276
1284
  /**
1277
1285
  * @docs
1278
- * @name image.experimentalBreakpoints
1286
+ * @name image.breakpoints
1279
1287
  * @type {number[]}
1280
1288
  * @default `[640, 750, 828, 1080, 1280, 1668, 2048, 2560] | [640, 750, 828, 960, 1080, 1280, 1668, 1920, 2048, 2560, 3200, 3840, 4480, 5120, 6016]`
1289
+ * @version 5.10.0
1281
1290
  * @description
1282
- * The breakpoints used to generate responsive images. Requires the `experimental.responsiveImages` flag to be enabled. The full list is not normally used,
1291
+ * The breakpoints used to generate responsive images. Requires a value for `layout` to be set. The full list is not normally used,
1283
1292
  * but is filtered according to the source and output size. The defaults used depend on whether a local or remote image service is used. For remote services
1284
1293
  * the more comprehensive list is used, because only the required sizes are generated. For local services, the list is shorter to reduce the number of images generated.
1285
1294
  */
1286
- experimentalBreakpoints?: number[];
1295
+ breakpoints?: number[];
1287
1296
  /**
1288
1297
  * @docs
1289
- * @name image.experimentalDefaultStyles
1298
+ * @name image.responsiveStyles
1290
1299
  * @type {boolean}
1291
- * @default `true`
1300
+ * @default `false`
1301
+ * @version 5.10.0
1292
1302
  * @description
1293
- * Whether to automatically add global styles to ensure that experimental images resize correctly. This is enabled by default, but can be disabled if you want to manage the styles yourself.
1294
- * This option is only used when the `experimental.responsiveImages` flag is enabled.
1303
+ * Whether to automatically add global styles for responsive images. You should enable this option unless you are styling the images yourself.
1304
+ * This option is only used when `layout` is set to `constrained`, `full-width`, or `fixed` using the configuration or the `layout` prop on the image component.
1305
+ *
1306
+ * See [the images docs](https://docs.astro.build/en/guides/images/#responsive-image-styles) for more information.
1295
1307
  */
1296
- experimentalDefaultStyles?: boolean;
1308
+ responsiveStyles?: boolean;
1297
1309
  };
1298
1310
  /**
1299
1311
  * @docs
@@ -1974,119 +1986,6 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
1974
1986
  * To use this feature with the Astro VS Code extension, you must also enable the `astro.content-intellisense` option in your VS Code settings. For editors using the Astro language server directly, pass the `contentIntellisense: true` initialization parameter to enable this feature.
1975
1987
  */
1976
1988
  contentIntellisense?: boolean;
1977
- /**
1978
- *
1979
- * @name experimental.responsiveImages
1980
- * @type {boolean}
1981
- * @default `undefined`
1982
- * @version 5.0.0
1983
- * @description
1984
- *
1985
- * Enables automatic responsive images in your project.
1986
- *
1987
- * ```js title=astro.config.mjs
1988
- * {
1989
- * experimental: {
1990
- * responsiveImages: true,
1991
- * },
1992
- * }
1993
- * ```
1994
- *
1995
- * When enabled, you can pass a `layout` props to any `<Image />` or `<Picture />` component to create a responsive image. When a layout is set, images have automatically generated `srcset` and `sizes` attributes based on the image's dimensions and the layout type. Images with `constrained` and `full-width` layouts will have styles applied to ensure they resize according to their container.
1996
- *
1997
- * ```astro title=MyComponent.astro
1998
- * ---
1999
- * import { Image, Picture } from 'astro:assets';
2000
- * import myImage from '../assets/my_image.png';
2001
- * ---
2002
- * <Image src={myImage} alt="A description of my image." layout='constrained' width={800} height={600} />
2003
- * <Picture src={myImage} alt="A description of my image." layout='full-width' formats={['avif', 'webp', 'jpeg']} />
2004
- * ```
2005
- * This `<Image />` component will generate the following HTML output:
2006
- * ```html title=Output
2007
- *
2008
- * <img
2009
- * src="/_astro/my_image.hash3.webp"
2010
- * srcset="/_astro/my_image.hash1.webp 640w,
2011
- * /_astro/my_image.hash2.webp 750w,
2012
- * /_astro/my_image.hash3.webp 800w,
2013
- * /_astro/my_image.hash4.webp 828w,
2014
- * /_astro/my_image.hash5.webp 1080w,
2015
- * /_astro/my_image.hash6.webp 1280w,
2016
- * /_astro/my_image.hash7.webp 1600w"
2017
- * alt="A description of my image"
2018
- * sizes="(min-width: 800px) 800px, 100vw"
2019
- * loading="lazy"
2020
- * decoding="async"
2021
- * fetchpriority="auto"
2022
- * width="800"
2023
- * height="600"
2024
- * style="--fit: cover; --pos: center;"
2025
- * data-astro-image="constrained"
2026
- * >
2027
- * ```
2028
- *
2029
- * The following styles are applied to ensure the images resize correctly:
2030
- *
2031
- * ```css title="Responsive Image Styles"
2032
- *
2033
- * :where([data-astro-image]) {
2034
- * object-fit: var(--fit);
2035
- * object-position: var(--pos);
2036
- * }
2037
- *
2038
- * :where([data-astro-image='full-width']) {
2039
- * width: 100%;
2040
- * }
2041
- *
2042
- * :where([data-astro-image='constrained']) {
2043
- * max-width: 100%;
2044
- * }
2045
- *
2046
- * ```
2047
- * You can enable responsive images for all `<Image />` and `<Picture />` components by setting `image.experimentalLayout` with a default value. This can be overridden by the `layout` prop on each component.
2048
- *
2049
- * **Example:**
2050
- * ```js title=astro.config.mjs
2051
- * {
2052
- * image: {
2053
- * // Used for all `<Image />` and `<Picture />` components unless overridden
2054
- * experimentalLayout: 'constrained',
2055
- * },
2056
- * experimental: {
2057
- * responsiveImages: true,
2058
- * },
2059
- * }
2060
- * ```
2061
- *
2062
- * ```astro title=MyComponent.astro
2063
- * ---
2064
- * import { Image } from 'astro:assets';
2065
- * import myImage from '../assets/my_image.png';
2066
- * ---
2067
- *
2068
- * <Image src={myImage} alt="This will use responsive layout" width={800} height={600} />
2069
- *
2070
- * <Image src={myImage} alt="This will use full-width layout" layout="full-width" />
2071
- *
2072
- * <Image src={myImage} alt="This will disable responsive images" layout="none" />
2073
- * ```
2074
- *
2075
- * #### Responsive image properties
2076
- *
2077
- * These are additional properties available to the `<Image />` and `<Picture />` components when responsive images are enabled:
2078
- *
2079
- * - `layout`: The layout type for the image. Can be `constrained`, `fixed`, `full-width` or `none`. Defaults to value of `image.experimentalLayout`.
2080
- * - `fit`: Defines how the image should be cropped if the aspect ratio is changed. Values match those of CSS `object-fit`. Defaults to `cover`, or the value of `image.experimentalObjectFit` if set.
2081
- * - `position`: Defines the position of the image crop if the aspect ratio is changed. Values match those of CSS `object-position`. Defaults to `center`, or the value of `image.experimentalObjectPosition` if set.
2082
- * - `priority`: If set, eagerly loads the image. Otherwise images will be lazy-loaded. Use this for your largest above-the-fold image. Defaults to `false`.
2083
- *
2084
- * The `widths` and `sizes` attributes are automatically generated based on the image's dimensions and the layout type, and in most cases should not be set manually. The generated `sizes` attribute for `constrained` and `full-width` images
2085
- * is based on the assumption that the image is displayed at close to the full width of the screen when the viewport is smaller than the image's width. If it is significantly different (e.g. if it's in a multi-column layout on small screens) you may need to adjust the `sizes` attribute manually for best results.
2086
- *
2087
- * The `densities` attribute is not compatible with responsive images and will be ignored if set.
2088
- */
2089
- responsiveImages?: boolean;
2090
1989
  /**
2091
1990
  *
2092
1991
  * @name experimental.fonts
@@ -2397,6 +2296,16 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
2397
2296
  *
2398
2297
  */
2399
2298
  preserveScriptOrder?: boolean;
2299
+ /**
2300
+ * @name experimental.liveContentCollections
2301
+ * @type {boolean}
2302
+ * @default `false`
2303
+ * @version 5.x
2304
+ * @description
2305
+ * Enables the use of live content collections.
2306
+ *
2307
+ */
2308
+ liveContentCollections?: boolean;
2400
2309
  };
2401
2310
  }
2402
2311
  /**
@@ -1,6 +1,7 @@
1
1
  import type { MarkdownHeading } from '@astrojs/markdown-remark';
2
2
  import type * as rollup from 'rollup';
3
3
  import type { DataEntry, RenderedContent } from '../../content/data-store.js';
4
+ import type { LiveCollectionError } from '../../content/loaders/errors.js';
4
5
  import type { AstroComponentFactory } from '../../runtime/server/index.js';
5
6
  import type { AstroConfig } from './config.js';
6
7
  export interface AstroInstance {
@@ -108,4 +109,33 @@ export type GetDataEntryInfoReturnType = {
108
109
  data: Record<string, unknown>;
109
110
  rawData?: string;
110
111
  };
112
+ export interface CacheHint {
113
+ /** Cache tags */
114
+ tags?: Array<string>;
115
+ /** Maximum age of the response in seconds */
116
+ maxAge?: number;
117
+ }
118
+ export interface LiveDataEntry<TData extends Record<string, any> = Record<string, unknown>> {
119
+ /** The ID of the entry. Unique per collection. */
120
+ id: string;
121
+ /** The parsed entry data */
122
+ data: TData;
123
+ /** A hint for how to cache this entry */
124
+ cacheHint?: CacheHint;
125
+ }
126
+ export interface LiveDataCollection<TData extends Record<string, any> = Record<string, unknown>> {
127
+ entries: Array<LiveDataEntry<TData>>;
128
+ /** A hint for how to cache this collection. Individual entries can also have cache hints */
129
+ cacheHint?: CacheHint;
130
+ }
131
+ export interface LiveDataCollectionResult<TData extends Record<string, any> = Record<string, unknown>, TError extends Error = Error> {
132
+ entries?: Array<LiveDataEntry<TData>>;
133
+ error?: TError | LiveCollectionError;
134
+ cacheHint?: CacheHint;
135
+ }
136
+ export interface LiveDataEntryResult<TData extends Record<string, any> = Record<string, unknown>, TError extends Error = Error> {
137
+ entry?: LiveDataEntry<TData>;
138
+ error?: TError | LiveCollectionError;
139
+ cacheHint?: CacheHint;
140
+ }
111
141
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.9.3",
3
+ "version": "5.10.0",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -64,6 +64,7 @@
64
64
  "./assets/services/noop": "./dist/assets/services/noop.js",
65
65
  "./assets/fonts/providers/*": "./dist/assets/fonts/providers/entrypoints/*.js",
66
66
  "./loaders": "./dist/content/loaders/index.js",
67
+ "./content/config": "./dist/content/config.js",
67
68
  "./content/runtime": "./dist/content/runtime.js",
68
69
  "./content/runtime-assets": "./dist/content/runtime-assets.js",
69
70
  "./debug": "./components/Debug.astro",
@@ -157,8 +158,8 @@
157
158
  "zod-to-json-schema": "^3.24.5",
158
159
  "zod-to-ts": "^1.2.0",
159
160
  "@astrojs/internal-helpers": "0.6.1",
160
- "@astrojs/telemetry": "3.3.0",
161
- "@astrojs/markdown-remark": "6.3.2"
161
+ "@astrojs/markdown-remark": "6.3.2",
162
+ "@astrojs/telemetry": "3.3.0"
162
163
  },
163
164
  "optionalDependencies": {
164
165
  "sharp": "^0.33.3"
@@ -6,12 +6,16 @@ import {
6
6
  createGetEntries,
7
7
  createGetEntry,
8
8
  createGetEntryBySlug,
9
+ createGetLiveCollection,
10
+ createGetLiveEntry,
9
11
  createReference,
10
12
  } from 'astro/content/runtime';
11
13
 
12
14
  export { defineCollection, renderEntry as render } from 'astro/content/runtime';
13
15
  export { z } from 'astro/zod';
14
16
 
17
+ /* @@LIVE_CONTENT_CONFIG@@ */
18
+
15
19
  const contentDir = '@@CONTENT_DIR@@';
16
20
 
17
21
  const contentEntryGlob = '@@CONTENT_ENTRY_GLOB_PATH@@';
@@ -56,12 +60,14 @@ export const getCollection = createGetCollection({
56
60
  dataCollectionToEntryMap,
57
61
  getRenderEntryImport: createGlobLookup(collectionToRenderEntryMap),
58
62
  cacheEntriesByCollection,
63
+ liveCollections,
59
64
  });
60
65
 
61
66
  export const getEntry = createGetEntry({
62
67
  getEntryImport: createGlobLookup(collectionToEntryMap),
63
68
  getRenderEntryImport: createGlobLookup(collectionToRenderEntryMap),
64
69
  collectionNames,
70
+ liveCollections,
65
71
  });
66
72
 
67
73
  export const getEntryBySlug = createGetEntryBySlug({
@@ -80,3 +86,11 @@ export const getDataEntryById = createGetDataEntryById({
80
86
  export const getEntries = createGetEntries(getEntry);
81
87
 
82
88
  export const reference = createReference({ lookupMap });
89
+
90
+ export const getLiveCollection = createGetLiveCollection({
91
+ liveCollections,
92
+ });
93
+
94
+ export const getLiveEntry = createGetLiveEntry({
95
+ liveCollections,
96
+ });
@@ -45,6 +45,10 @@ declare module 'astro:content' {
45
45
  collection: C;
46
46
  slug: E;
47
47
  };
48
+ export type ReferenceLiveEntry<C extends keyof LiveContentConfig['collections']> = {
49
+ collection: C;
50
+ id: string;
51
+ };
48
52
 
49
53
  /** @deprecated Use `getEntry` instead. */
50
54
  export function getEntryBySlug<
@@ -73,6 +77,13 @@ declare module 'astro:content' {
73
77
  filter?: (entry: CollectionEntry<C>) => unknown,
74
78
  ): Promise<CollectionEntry<C>[]>;
75
79
 
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
+
76
87
  export function getEntry<
77
88
  C extends keyof ContentEntryMap,
78
89
  E extends ValidContentEntrySlug<C> | (string & {}),
@@ -109,6 +120,10 @@ declare module 'astro:content' {
109
120
  ? Promise<DataEntryMap[C][E]> | undefined
110
121
  : Promise<DataEntryMap[C][E]>
111
122
  : 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>>>;
112
127
 
113
128
  /** Resolve an array of entry references from the same collection */
114
129
  export function getEntries<C extends keyof ContentEntryMap>(
@@ -152,5 +167,33 @@ declare module 'astro:content' {
152
167
 
153
168
  type AnyEntryMap = ContentEntryMap & DataEntryMap;
154
169
 
170
+ type ExtractLoaderTypes<T> = T extends import('astro/loaders').LiveLoader<
171
+ infer TData,
172
+ infer TEntryFilter,
173
+ infer TCollectionFilter,
174
+ infer TError
175
+ >
176
+ ? { data: TData; entryFilter: TEntryFilter; collectionFilter: TCollectionFilter; error: TError }
177
+ : { data: never; entryFilter: never; collectionFilter: never; error: never };
178
+ type ExtractDataType<T> = ExtractLoaderTypes<T>['data'];
179
+ type ExtractEntryFilterType<T> = ExtractLoaderTypes<T>['entryFilter'];
180
+ type ExtractCollectionFilterType<T> = ExtractLoaderTypes<T>['collectionFilter'];
181
+ type ExtractErrorType<T> = ExtractLoaderTypes<T>['error'];
182
+
183
+ type LiveLoaderDataType<C extends keyof LiveContentConfig['collections']> =
184
+ LiveContentConfig['collections'][C]['schema'] extends undefined
185
+ ? ExtractDataType<LiveContentConfig['collections'][C]['loader']>
186
+ : import('astro/zod').infer<
187
+ Exclude<LiveContentConfig['collections'][C]['schema'], undefined>
188
+ >;
189
+ type LiveLoaderEntryFilterType<C extends keyof LiveContentConfig['collections']> =
190
+ ExtractEntryFilterType<LiveContentConfig['collections'][C]['loader']>;
191
+ type LiveLoaderCollectionFilterType<C extends keyof LiveContentConfig['collections']> =
192
+ ExtractCollectionFilterType<LiveContentConfig['collections'][C]['loader']>;
193
+ type LiveLoaderErrorType<C extends keyof LiveContentConfig['collections']> = ExtractErrorType<
194
+ LiveContentConfig['collections'][C]['loader']
195
+ >;
196
+
155
197
  export type ContentConfig = '@@CONTENT_CONFIG_TYPE@@';
198
+ export type LiveContentConfig = '@@LIVE_CONTENT_CONFIG_TYPE@@';
156
199
  }
@@ -1,85 +1,24 @@
1
1
  declare module 'astro:content' {
2
2
  export { z } from 'astro/zod';
3
-
4
- // This needs to be in sync with ImageMetadata
5
- export type ImageFunction = () => import('astro/zod').ZodObject<{
6
- src: import('astro/zod').ZodString;
7
- width: import('astro/zod').ZodNumber;
8
- height: import('astro/zod').ZodNumber;
9
- format: import('astro/zod').ZodUnion<
10
- [
11
- import('astro/zod').ZodLiteral<'png'>,
12
- import('astro/zod').ZodLiteral<'jpg'>,
13
- import('astro/zod').ZodLiteral<'jpeg'>,
14
- import('astro/zod').ZodLiteral<'tiff'>,
15
- import('astro/zod').ZodLiteral<'webp'>,
16
- import('astro/zod').ZodLiteral<'gif'>,
17
- import('astro/zod').ZodLiteral<'svg'>,
18
- import('astro/zod').ZodLiteral<'avif'>,
19
- ]
20
- >;
21
- }>;
22
-
23
- export interface DataEntry {
24
- id: string;
25
- data: Record<string, unknown>;
26
- filePath?: string;
27
- body?: string;
28
- }
29
-
30
- export interface DataStore {
31
- get: (key: string) => DataEntry;
32
- entries: () => Array<[id: string, DataEntry]>;
33
- set: (key: string, data: Record<string, unknown>, body?: string, filePath?: string) => void;
34
- values: () => Array<DataEntry>;
35
- keys: () => Array<string>;
36
- delete: (key: string) => void;
37
- clear: () => void;
38
- has: (key: string) => boolean;
39
- }
40
-
41
- export interface MetaStore {
42
- get: (key: string) => string | undefined;
43
- set: (key: string, value: string) => void;
44
- delete: (key: string) => void;
45
- has: (key: string) => boolean;
46
- }
47
-
48
- export type BaseSchema = import('astro/zod').ZodType;
49
-
50
- export type SchemaContext = { image: ImageFunction };
51
-
52
- type ContentLayerConfig<S extends BaseSchema, TData extends { id: string } = { id: string }> = {
53
- type?: 'content_layer';
54
- schema?: S | ((context: SchemaContext) => S);
55
- loader:
56
- | import('astro/loaders').Loader
57
- | (() =>
58
- | Array<TData>
59
- | Promise<Array<TData>>
60
- | Record<string, Omit<TData, 'id'> & { id?: string }>
61
- | Promise<Record<string, Omit<TData, 'id'> & { id?: string }>>);
62
- };
63
-
64
- type DataCollectionConfig<S extends BaseSchema> = {
65
- type: 'data';
66
- schema?: S | ((context: SchemaContext) => S);
67
- };
68
-
69
- type ContentCollectionConfig<S extends BaseSchema> = {
70
- type?: 'content';
71
- schema?: S | ((context: SchemaContext) => S);
72
- loader?: never;
73
- };
74
-
75
- export type CollectionConfig<S extends BaseSchema> =
76
- | ContentCollectionConfig<S>
77
- | DataCollectionConfig<S>
78
- | ContentLayerConfig<S>;
79
-
80
- export function defineCollection<S extends BaseSchema>(
81
- input: CollectionConfig<S>,
82
- ): CollectionConfig<S>;
3
+ export type {
4
+ ImageFunction,
5
+ DataEntry,
6
+ DataStore,
7
+ MetaStore,
8
+ BaseSchema,
9
+ SchemaContext,
10
+ } from 'astro/content/config';
11
+
12
+ export function defineLiveCollection<
13
+ L extends import('astro/loader').LiveLoader,
14
+ S extends import('astro/content/config').BaseSchema | undefined = undefined,
15
+ >(
16
+ config: import('astro/content/config').LiveCollectionConfig<L, S>,
17
+ ): import('astro/content/config').LiveCollectionConfig<L, S>;
18
+
19
+ export function defineCollection<S extends import('astro/content/config').BaseSchema>(
20
+ config: import('astro/content/config').CollectionConfig<S>,
21
+ ): import('astro/content/config').CollectionConfig<S>;
83
22
 
84
23
  /** Run `astro dev` or `astro sync` to generate high fidelity types */
85
24
  export const getEntryBySlug: (...args: any[]) => any;
@@ -106,4 +45,8 @@ declare module 'astro:content' {
106
45
  export type ContentConfig = any;
107
46
  /** Run `astro dev` or `astro sync` to generate high fidelity types */
108
47
  export const render: (entry: any) => any;
48
+ /** Run `astro dev` or `astro sync` to generate high fidelity types */
49
+ export const getLiveCollection: (...args: any[]) => any;
50
+ /** Run `astro dev` or `astro sync` to generate high fidelity types */
51
+ export const getLiveEntry: (...args: any[]) => any;
109
52
  }