feat: added types to allow the creation of user space content services (#7607)
* feat: added types to astro:content to allow user space content services * Create small-apes-clap.md --------- Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
This commit is contained in:
parent
91380378ce
commit
45364c3452
2 changed files with 12 additions and 2 deletions
5
.changeset/small-apes-clap.md
Normal file
5
.changeset/small-apes-clap.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"astro": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add `CollectionKey`, `ContentCollectionKey`, and `DataCollectionKey` exports to `astro:content`
|
9
packages/astro/content-types.template.d.ts
vendored
9
packages/astro/content-types.template.d.ts
vendored
|
@ -11,8 +11,13 @@ declare module 'astro:content' {
|
||||||
declare module 'astro:content' {
|
declare module 'astro:content' {
|
||||||
export { z } from 'astro/zod';
|
export { z } from 'astro/zod';
|
||||||
|
|
||||||
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
|
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
|
||||||
export type CollectionEntry<C extends keyof AnyEntryMap> = Flatten<AnyEntryMap[C]>;
|
|
||||||
|
export type CollectionKey = keyof AnyEntryMap;
|
||||||
|
export type CollectionEntry<C extends CollectionKey> = Flatten<AnyEntryMap[C]>;
|
||||||
|
|
||||||
|
export type ContentCollectionKey = keyof ContentEntryMap;
|
||||||
|
export type DataCollectionKey = keyof DataEntryMap;
|
||||||
|
|
||||||
// This needs to be in sync with ImageMetadata
|
// This needs to be in sync with ImageMetadata
|
||||||
export type ImageFunction = () => import('astro/zod').ZodObject<{
|
export type ImageFunction = () => import('astro/zod').ZodObject<{
|
||||||
|
|
Loading…
Reference in a new issue